Actually all of the controls throw NotImplemented, it looks like it is an issue with MEF not loading the ControlTypesToSpellChecker. I can manually load the SpellCheckers threw the manager however. This might be a result of the fact that this is an external module, however MEF should still be able to discover the dlls.
12 Answers, 1 is accepted
We tried several scenarios to reproduce the issue you are mentioning. The only problem we found was when "Reduce XAP size by using application library caching" Silverlight project option is enabled. The problem here consists in that the assemblies are loaded when demanded, so MEF is not able to find them initially. As a work around (which you could have found yourself) we can recommend the following:
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"
));
As MEF couldn't load the ControlSpellCheckers the dictionary you mentioned remains empty, so you can fill it with the
ConWetrolSpellCheckersManager.RegisterControlSpellChecker
method, providing an instance of a class derived from IControlSpellChecker as argument(such IControlSpellCheckers exist for TextBox, RadRichTextBox and RichTextBox in the Telerik.Windows.Control.Proofing namespace).
We realize that this solution is far from perfect and we will do our best to find a better one. However for the time being we recommend this approach.
Don't hesitate to contact us again.
Andrew
the Telerik team
private void buttoncheckspelling_click(object sender, RoutedEventArgs e)
{
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"));
//RadSpellChecker.Check(this.KeyWordTextbox, SpellCheckingMode.AllAtOnce); //object reference not set to an instance...
documentSpellChecker.CheckWordIsCorrect(this.KeyWordTextbox.Text); //does not bring up the SpellChecker box like in the demo
}
????
The code you wrote, is necessary only when the Project Properties option "Reduce XAP size by using application library caching" is enabled. Then Silverlight downloads assemblies on demand so MEF can't load the ControlSpellCheckers and that's why we need to do that manually.
Now to your question, the method you use DocumentSpellChecker.CheckWordIsCorrect(string text) returns boolean value indicating whether the word provided as argument is in the current dictionary. If you want to show the spellchecking window like in the demo, use RadSpellChecker.Check method.(which you have commented in your ticket)
If you have other questions contact us again.
Andrew
the Telerik team
Well, that happens because the SpellCheckAllAtOnce dialog uses RadRichTextBox to present the whole content of the control being spellchecked. So in order to make it work, first you need to register the ControlSpellChecker for the RadRichTextBox and then add a dictionary to it.
The following code presents what i mean:
ControlSpellCheckersManager.RegisterControlSpellChecker(
new
TextBoxSpellChecker());
ControlSpellCheckersManager.RegisterControlSpellChecker(
new
RadRichTextBoxSpellChecker());
IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(
typeof
(RadRichTextBox));
ISpellChecker spellChecker = controlSpellchecker.SpellChecker;
DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
documentSpellChecker.AddDictionary(
new
RadEn_USDictionary(),
new
System.Globalization.CultureInfo(
"en-US"
));
RadSpellChecker.Check(
this
.textBox1, SpellCheckingMode.AllAtOnce);
You simply put this code snippet in your button_Click EventHandler and everything should be fine.
Thank you for pointing this out. We realize that throwing null reference exception is not the best behavior in this case and will change it with more informative message.
Andrew
the Telerik team
Most of the times this happens when there is no dictionary loaded. Probably you forgot to add a reference to "Telerik.Windows.Documents.Proofing.Dictionaries.En-US" assembly where our default dictionary resides.
Kind regards,Andrew
the Telerik team
Documents.Proofing
Documents.Proofing.Dictionaries.En-US
still not working and My name is JJ
The only reason why no suggestions are shown in the context menu can be that there are no words "similar enough" in the dictionary. The spell checker uses an algorithm for calculating the distance between words in the dictionary and misspelled words. If that distance is bigger than a fixed value, the word is not considered fit for a suggestion.
This is not the case for "foxxx". We suspect that there might be something with the theme you are using that messes up with the suggestion, so we would appreciate it if you could send us a sample project in a General Feedback ticket, so that we can look into the issue and solve the mystery.
Iva
the Telerik team
I think it is the dictionary did not add(debuging after documentSpellChecker.AddDictionary(...)) after adding it in the code - dictionaryempty.png , I tried both en-US and en-ZA, same thing...
Answer:
this is a silver-light project, the problem is that I tried to load the dictionaries in code-behind of the button click, no time to asynchronous load there, but when I shift the code you guys gave me to the App.xaml.cs in Application_Startup it works...
thanks guys
We are glad to hear that you managed to identify the problem and resolve it.
Best wishes,Iva
the Telerik team