开发者

Improving WPF RichTextBox Language Support?

开发者 https://www.devze.com 2022-12-09 22:56 出处:网络
After a bit of digging it would appear that the WPF built in spell checker only supports English, Spanish, French, and German - which beggars belief somew开发者_JAVA百科hat. I can understand they can\

After a bit of digging it would appear that the WPF built in spell checker only supports English, Spanish, French, and German - which beggars belief somew开发者_JAVA百科hat. I can understand they can't really ship comprehensive spell checkers for every language with WPF, but I'd at least expect it to be able to use the Office ones if they are installed.

Rant aside, has anyone had any success in replacing the current dictionary with one with wider language support, either by rolling your own or using a 3rd party component? A quick search throws up a few possibilities, but I'd appreciate any advice from anyone with first hand experience. This particular product has an international audience, so language support needs to be pretty comprehensive.


The first thing to say is that, from my understanding, .NET 4 WPF spell checking has support for alternate dictionaries, so waiting or building on the betas may very well be the most cost-effective option for you.

I worked on a WPF project that had a requirement for a medical-grade spell check dictionary, which of course is not supported in the built-in spell checking of .NET 3.x. What we ended up doing was integrating with a 3rd party COM spell checking component, and basically overriding the spell check behavior logic to re-implement it ourselves -- running each word through the dictionary and adding a "red underline" adorner to misspelled words, and adding a mouse-over popup control to show and allow selection of alternate spellings.

This is non-trivial, as you need to modify the xml of the flow document to be able to add adorners, and you need to be smart about filtering out punctuation, etc., as well as when and how often to check the spelling of words/paragraphs.

There may now be 3rd party WPF 3.x spell-checkable text areas, I know there were not any available at the time we developed our product.

Good luck, and I hope this helps.


For those that care we ended up "rolling our own" using NHunspell. We lose the red squiggleys, which is a shame, but the F7 Word style spellcheck dialog does the job.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号