views:

975

answers:

1

Hi,

If I define a RichTextBox as follows;

<RichTextBox SpellCheck.IsEnabled="True">
    <FlowDocument />
</RichTextBox>

When I type in the work 'Sample' and make the first three letters bold, the spell checker underlines the word.

The source XAML of the document shows that the RichTextBox is splitting the word into two seperate runs;

<Paragraph>
    <Run FontWeight="Bold" xml:lang="en-gb">Sam</Run>
    <Run xml:lang="en-gb">ple</Run>
</Paragraph>

If I manually contruct a document with the following blocks;

<FlowDocument>
    <Paragraph>
        <Run FontWeight="Bold">Sam</Run>ple
    </Paragraph>
</FlowDocument>

The spell checker passed the word successfully.

Has anyone come across this before? Is there a workaround that I can use?

Thanks Matt

A: 

There seem to be issues with the spell checker and different locales.

If I start with this:

<RichTextBox SpellCheck.IsEnabled="True" xml:lang="en-GB">
    <FlowDocument />
</RichTextBox>

I can reproduce your error (by typing "Sample" and bolding the "Sam"), but not with this:

<RichTextBox SpellCheck.IsEnabled="True">
    <FlowDocument />
</RichTextBox>

Someone has a similar problem here. Microsoft replies:

This problem occurs because the Language property on FrameworkElement (and thus TextBox/RichTextBox) defaults to "en-US", and you are using the "en-NZ" locale. When you type text into TextBox/RichTextBox, it will be in a different locale than the text set in XAML. The spell checker does not cross language boundaries, which results in the behavior you see.

Robert Macnee
Thank you for the reply and the link to MS page. It looks as though the best option for me to wait until .Net 4.0.