Modal Spell-Checking

To implement modal spell checking, you start by adding to your project a reference to the C1.Silverlight.SpellChecker assembly. Then, add the following code to your project:

      Visual Basic

      C#

The code creates a new C1SpellChecker object to be shared by all controls on the page that require spell-checking.

Later, the page constructor invokes the LoadAsync method to load the main spell dictionary. In this case, we are loading C1Spell_en-US.dct, the American English dictionary. This file must be present on the application folder on the server. C1SpellChecker includes over 20 other dictionaries which can be downloaded from our site.

The code adds a handler to the SpellDictionaryBase.LoadCompleted event so it can detect when the main dictionary finishes loading and whether there were any errors. Here is a typical event handler:

      Visual Basic

      C#

The code also loads a user dictionary from isolated storage. This step is optional. The user dictionary stores words such as names and technical terms. The code attaches an event handler to the application's Exit event to save the user dictionary when the application finishes executing:

      Visual Basic

      C#

Once the dictionary has been loaded, you can invoke the modal spell-checker by calling the C1SpellChecker.CheckControlAsync method. For example:

      Visual Basic

      C#

The code calls C1SpellChecker.CheckControlAsync. When the modal checking is complete, the C1SpellChecker.CheckControlCompleted event fires and shows a dialog box to indicate that the spell-checking operation is complete.

The image below shows the spell-checking dialog box in action:

 


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.