This is a migrated thread and some comments may be shown as answers.

how to use RadSpellChecker in mvvm

1 Answer 111 Views
SpellChecker
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 04 Sep 2013, 08:17 PM
I am trying to add RadSpellChecker to our SilverLight application which is using MVVM.

I have added these assemblies to the project: Telerik.Windows.Documents.Proofing,Telerik.Windows.Documents.Proofing.En-US

The textbox "Text" property on my View is bound to Text="{Binding Model.Description}"
The Button "Command" is Command="{Binding Model.SpellcheckCommand}"

In my ViewModel I have added these namespaces
using Telerik.Windows.Documents;
using Telerik.Windows.Controls;

In the SpellChecker method in the ViewModel I have the following but the RadSpellChecker says I'm missing an assembly reference.
        public void SpellCheck()
        {
            Telerik.Windows.Controls.RadSpellChecker.Check(Model.Description, SpellCheckingMode.WordByWord);
        }

Do I have to call RadSpellChecker from the View's code behind instead?

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 06 Sep 2013, 03:34 PM
Hello Jerry,

From your explanation it seems you are trying to pass the string property to which the TextBox is bound to the spellchecker, is that correct? RadSpellChecker's Check() method requires a Control instance to be passed as parameter. That said, I'd suggest you pass the TextBox from your view as a command parameter.

Additionally, in some cases MEF is unable to load the needed spellchecker. To resolve the problem you can register the spellcheckers for TextBox before the RadSpellChecker.Check() call like this:
ControlSpellCheckersManager.RegisterControlSpellChecker(new TextBoxSpellChecker());
 
IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(TextBox));
ISpellChecker spellChecker = controlSpellchecker.SpellChecker;
DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
documentSpellChecker.AddDictionary(new RadEn_USDictionary(), new System.Globalization.CultureInfo("en-US"));

I hope this helps!

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
SpellChecker
Asked by
Jerry
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or