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"));
in the App.xaml.cs in "Application_Startup"
Thanks
9 Answers, 1 is accepted
The code you are using is correct. The problem may be appearing, because your current culture is set to something different from en-US. Thus the spellchecker is not using the dictionary you explicitly have loaded.
To fix that, add the following line to your code:
documentSpellChecker.SpellCheckingCulture =
new
System.Globalization.CultureInfo(
"en-US"
);
If that doesn't help contact us again, so we can investigate further. Best wishes,
Andrew
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
Thanks
Paul
We are glad that this solved your problem, in a way. So now, to your next questions.
You can create another assembly similar to Telerik.Windows.Documents.Proofing.Dictionaries.En-US which loads dictionary you have chosen. To do that you have to create a Silverlight Class Library project. Add the .tdf file, set its Build Action to Resource and Copy to Output Directory to Copy if newer.
Now the only thing you have to do is to create a class which inherits from RadDictionary, which in turn implements a method that loads the .tdf file. The following code shows how to achieve that for a German dictionary.
[WordDictionaryMetadata(
"de-DE"
)]
public
class
RadDe-DEDictionary : RadDictionary
{
public
RadDe-DEDictionary()
{
}
protected
override
void
EnsureDictionaryLoadedOverride()
{
Stream stream = Application.GetResourceStream(
new
Uri(
"RadDe;component/de-DE.tdf"
, UriKind.Relative)).Stream;
this
.Load(stream);
}
}
For the MEF to be able to discover this assembly you need to do one more thing. You should add the following line to the Application_Startup eventhandler.
RadCompositionInitializer.Container =
new
CompositionContainer(
new
SafeXapCatalog());
Now you are good to go. When you add a reference to that assembly in your project and set the SpellCheckingCulture to "de-DE" for example, this .tdf file will be used for spellchecking.
Some side notes:
1. RadDictionary resides in Telerik.Windows.Documents assembly in Telerik.Windows.Documents.Proofing namespace.
2. To use the WordDictionaryMetadata attribute in your Silverlight Class Library project you have to add a reference to System.ComponentModel.Composition
If this doesn't help you, contact us again. Best wishes,
Andrew
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
RadCompositionInitializer.Container =
new
CompositionContainer(
new
SafeXapCatalog());
Regards
Paul
How do i avoid writing anything in the Application_Startup eventhandler.
My scenario is such that, i have created custom controls in a library. And, i have implemented the IControlSpellChecker interface.
Also, added the different .tdf files to the same library (as suggested).
Now, how do i use the CustomDictioanries (from the same assembly)?
I dont want to write the RadCompositionInitializer in every SilverLight application that i create. Is it possible to refernce it from within the custom controls dll.
Paul,
Can you please tell how did u achieve this ?
In that case, you can add the line from Paul's snippet in the constructor of your custom control, just before the InitializeComponent invocation like this:
public
SpellCheckingControl()
{
RadCompositionInitializer.Container =
new
CompositionContainer(
new
SafeXapCatalog());
InitializeComponent();
}
Iva
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Referring to your response (Posted on Jul 14, 2011), i did exactly the same things.
- Created a Silverlight Class Library project.
- Added .tdf files to that (set the Build action and the Copy to output Directory).
- Created class inheriting from RadDictionary.
- Added the WordDictionaryMetadata attribute with proper Culture.
- Added the CompositionInitializer line.
- And finally, set the SpellCheckingCulture.
But, when i dynamically change the SpellCheckingCulture, i dont see the respective dictionaries getting loaded.
Everytime, the spellchecker is using the default english language.
I have tried to get the spellCheckingCulture just before calling the RadSpellChecker.Check() method also. It says the SpellCheckingCulture is set to whatever i set to. But still, it is not able to load the respective dictionary.
Am i missing something ?
One more point:
If, instead of setting the spell checking culture, i set the Thread.CurrentThread.CurrentUICulture, then in that case, it is loading the respective dictionary.
Isn't it possible to set the language (for dictionary to use) only for SpellChecker (as in asp.net spellCheck) ??
Please respond asap.
Thanks
The localization language is independent from the spell-checking language.
There is a demo and further explanations of how RadSpellChecker can be used with different languages and how they can be changed runtime here.
More information on localizing RadControls for Silverlight can be found in our online documentation. The list of all strings that RadSpellChecker uses has been published in this forum post.
If you are experiencing any difficulties, we would appreciate some more details or a sample project illustrating the issue.
Iva
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>