New to Telerik UI for WPF? Download free 30-day trial

SpellChecking Custom Controls

RadSpellChecker supports Custom Controls. Internally it holds a dictionary matching a Type to an instance of a class deriving from IControlSpellChecker. These instances are loaded through MEF. Ultimately, if you implement this interface you can use RadSpellChecker with your own controls.

Implementing IControlSpellChecker

  • Properties:

Type SupportedControlType { get; }: The Type of the control implementing IControlSpellChecker

Control CurrentControl { get; set; }: A reference to the control

IIgnoredWordDictionary IgnoredWords { get; set; }: A collection where all the ignored words are stored

ISpellChecker SpellChecker { get; }: An instance of a class implementing ISpellChecker(you can use DocumentSpellChecker or a custom class of yours).

The Telerik.Windows.Documents.Proofing assembly contains an abstract class named ControlSpellCheckerBase which derives from IControlSpellChecker and implements the last two properties (IgnoredWords and SpellChecker). If the implementation in the abstract class proves to be fit for your control, you can derive from this class instead.

  • Methods:

IWordInfo MoveToNextError() - searches the control for the next error(if there is one) and selects the wrong word. void ChangeCurrentWord(string suggestion) - gets the selected word and replaces it with the right one selected by the user.

RadDocument GetContentAsDocument() - gets the text that has to be spellchecked from your control and imports it in the RadRichTextBox, which the window uses void SetContentFromDocument(RadDocument document) - gets the spellchecked text from the RadRichTextBox and sets it back to your control

In this article