1

如果我定义一个 RichTextBox 如下;

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

当我输入作品“Sample”并将前三个字母加粗时,拼写检查器会在单词下划线。

文档的源 XAML 显示 RichTextBox 将单词分成两个单独的运行;

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

如果我手动构建具有以下块的文档;

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

拼写检查器成功通过了单词。

有没有人遇到过这个?有我可以使用的解决方法吗?

谢谢马特

4

1 回答 1

1

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.

于 2009-03-13T18:26:01.287 回答