Working with C1SpellChecker > Concepts and Main Properties > Spelling Dictionaries > UserDictionary |
The user dictionary is a read-write word list that contains terms defined by users, such as names and technical jargon (for example "ComponentOne," "Silverlight," and so on). Users can add words to the custom dictionary while checking spelling by clicking the "Add" button in the spelling dialog box. You can also add and remove words using code.
The user dictionary is typically stored in the applications isolated storage, rather than on the server. You can load and save the custom dictionary using the LoadFromIsolatedStorage and SaveToIsolatedStorage methods as shown below:
C# |
Copy Code
|
---|---|
public Page() { InitializeComponent(); // Other initialization... // Load main dictionary SpellDictionary md = c1SpellChecker1.MainDictionary; md.LoadCompleted += md_LoadCompleted; md.LoadProgressChanged += md_LoadProgressChanged; md.LoadAsync("C1Spell_en-US.dct"); // Load user dictionary UserDictionary ud = c1SpellChecker1.UserDictionary; ud.LoadFromIsolatedStorage("Custom.dct"); // Save user dictionary when app exits App.Current.Exit += App_Exit; } void App_Exit(object sender, EventArgs e) { // Save modified user dictionary into compressed isolated storage UserDictionary ud = c1SpellChecker1.UserDictionary; ud.SaveToIsolatedStorage("Custom.dct"); } |
The code loads the user dictionary from isolated storage, and attaches an event handler to save any changes when the application exits. The user dictionary is typically small, and it is saved in compressed format, so it does not take up much storage space.
You can also load and save user dictionaries to Stream objects, so you can customize the persistence mechanism for the user dictionary if you want.