How to add a custom dictionary to RadSpellChecker

7 posts, 1 answers
  1. Frank
    Frank avatar
    8 posts
    Member since:
    Mar 2011

    Posted 31 Mar 2011 Link to this post

    Hello,
    I am using your RadSpellChecker class to perform the spell checking on a standard silverlight textbox but I wasn't able to figure out how to load a custom dictionary (a .tdf file) like I am doing with your RadRichTextBox class.

    It seems that the spellchecker in your RadRichTextBox implements the interface ISpellCheker while your RadSpellChecker is a static class deriving from the Object class.
    Because of that I don't see any AddDictionary method in the RadSpellChecker class that allows me to import my dictionary.

    Any help would be really appreciated.

    Thanks,
    Frank
  2. Frank
    Frank avatar
    8 posts
    Member since:
    Mar 2011

    Posted 05 Apr 2011 Link to this post

    Hello,
    Do you have any update on this open question?

    Thanks,
    Frank
  3. DevCraft banner
  4. Answer
    Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 05 Apr 2011 Link to this post

    Hi Frank,

    Thank you for your question. The problem you are referring to, has a solution, although it might not be so intuitive. Actually RadSpellChecker is using a dictionary that matches a Type to a corresponding manager of type IControlSpellChecker. We have a public static class called ControlSpellCheckersManager which has a static method GetControlSpellChecker(Type type). Using this method you can access the corresponding IControlSpellChecker and get it's SpellChecker property which is of type ISpellChecker. Then if you want you can cast it to DocumentSpellChecker and use all it's methods. Here is the code to do this:

    IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(TextBox));
    ISpellChecker spellChecker = controlSpellchecker.SpellChecker;
    DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
    Then you can call documentSpellChecker.AddDictionary().
    We will consider simplifying this functionality in the next version.

    Kind regards,
    Andrew
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Frank
    Frank avatar
    8 posts
    Member since:
    Mar 2011

    Posted 05 Apr 2011 Link to this post

    Hi Andrew,
    Thank you very much.
    This was what I was looking for.

    I agree with you that it would be great if you could make the process more intuitive or, at least, documented somewhere because I wasn't able to find the RadSpellCheck class (or your ControlSpellCheckersManager class) between your online documentation.

    Fortunately you offer such great customer support!! ;)

    Thanks again,
    Frank
  6. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 08 Apr 2011 Link to this post

    Hi Frank,

    Thank you for the positive feedback.
    We agree that this information should be included in the documentation and will do our best to do so shortly.

    Regards,
    Iva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Kotte
    Kotte avatar
    48 posts
    Member since:
    Feb 2011

    Posted 12 Oct 2011 Link to this post

    Hi ,
    I am trying to add a custom dictionary ..

    I created Test.txt file with few words and added to the project and loading to IsolatedStorage

    IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();          
    isoStore.CreateDirectory("SpellCheck");
    IsolatedStorageFileStream isoStream1 =  new IsolatedStorageFileStream("Test.txt", FileMode.Create, isoStore);
    isoStream1.Close();

    Creating the Custom Dictionary..
    RadIsolatedStorageCustomDictionary dictionary = new RadIsolatedStorageCustomDictionary(IsolatedStorageScope.Application, "Test.txt");
    DocumentSpellChecker spellchecker = new DocumentSpellChecker(dictionary);
    this._richTextBox.SpellChecker = spellchecker;


    Adding Dictionary
     Stream tdfFileStream = Application.GetResourceStream(new Uri("/MC.Client.Controls;component/Resources/en-US.tdf", UriKind.RelativeOrAbsolute)).Stream;
     RadDictionary dictionary1 = new RadDictionary();
     dictionary1.Load(tdfFileStream);
     ((DocumentSpellChecker)this._richTextBox.SpellChecker).AddDictionary(dictionary, CultureInfo.CurrentCulture);

    its still showing the default dictionary and I did not find the words from Test.txt file.
    Am I missing any thing.
    Can you please post a sample working project which loads custom dictionary file like (ex: CustomDictionary.txt )

    Thanks,
    Kotte
  8. Kotte
    Kotte avatar
    48 posts
    Member since:
    Feb 2011

    Posted 13 Oct 2011 Link to this post

    Hi,


    I am able to fix the issue.Its working fine now.


    Thanks,
    Kotte
Back to Top
DevCraft banner