Silverlight's RichTextBox.Xaml vs. CurrentCulture
There appears to be a bug in the current version (4) of Silverlight and its RichTextBox control.
The RichTextBox.Xaml property contains a XAML representation of the box's content in form of a System.String. This property is both settable and gettable, which means that there must be serialization and deserialization happening on some level.
The problem is, that serialization (getting the RichTextBox.Xaml property) handles cultural differences differently than deserialization (setting the RichTextBox.Xaml property).
In my case RichTextBox.Xaml.get produces XAML with comma as the decimal separator (correct for my culture), but attempting to set the same XAML back to RichTextBox.Xaml throws an exception - it expects dots (US culture), not commas.
I've solved the problem by setting
The RichTextBox.Xaml property contains a XAML representation of the box's content in form of a System.String. This property is both settable and gettable, which means that there must be serialization and deserialization happening on some level.
The problem is, that serialization (getting the RichTextBox.Xaml property) handles cultural differences differently than deserialization (setting the RichTextBox.Xaml property).
In my case RichTextBox.Xaml.get produces XAML with comma as the decimal separator (correct for my culture), but attempting to set the same XAML back to RichTextBox.Xaml throws an exception - it expects dots (US culture), not commas.
I've solved the problem by setting
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
Labels: RichTextBox, serialization, silverlight, Xaml