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

Trouble Toggling spellchecker from a RadMenuItem

1 Answer 62 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 07 Dec 2010, 04:58 PM
So I am trying to set it up so I can toggle spellcheck from a Menu, rather than from the ribbon bar.  I have this working for the RadRichTextBox bold, italics, underline, copy, cut, and paste methods, but it doesn't work for the ToggleSpellCheckingCommand.

For example, my code reads
<telerikNavigation:RadMenuItem Header="Format">
                    <telerikNavigation:RadMenuItem x:Name="_boldMenu" DataContext="{Binding ElementName=_rrtb}" Command="{Binding ToggleBoldCommand}" Header="Bold" />
                    <telerikNavigation:RadMenuItem x:Name="_italicMenu" DataContext="{Binding ElementName=_rrtb}" Command="{Binding ToggleItalicCommand}" Header="Italic" />
                    <telerikNavigation:RadMenuItem x:Name="_underlineMenu" DataContext="{Binding ElementName=_rrtb}" Command="{Binding ToggleUnderlineCommand}" Header="Underline" />
</telerikNavigation:RadMenuItem>
<telerikNavigation:RadMenuItem Header="Tools">
                    <telerikNavigation:RadMenuItem x:Name="_spellCheckMenu" DataContext="{Binding ElementName=_rrtb}" Command="{Binding ToggleSpellCheckingCommand}" Header="SpellCheck" />

The Bold, Italic, and Underline work, but the SpellChecking doesn't.  Any ideas?

1 Answer, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 10 Dec 2010, 10:08 AM
Hi Michael,
The reason _spellCheckMenu menu item is not working is that ToggleSpellCheckingCommand doesn't exists in RadRichTextBox.
In the initial versions of RadRichTextBox it has properties for every command that can be executed on it, for example RadRichTextBox.ToggleBoldCommand and RadRichTextBox.ToggleItalicCommand. Later these properties have been deprecated, as we extracted them to another class, named  RichTextBoxCommands. All new  commands are added only to there (this is the case with ToggleSpellCheckingCommand). An instance of it can be obtained through RadRichTextBox.Commands property.

In your case you are actually binding menu items to the deprecated properties, and the code that should work will be something like the following:
<telerikNavigation:RadMenuItem Header="Format">
    <telerikNavigation:RadMenuItem x:Name="_boldMenu" Header="Bold"  DataContext="{Binding ElementName=_rrtb}" Command="{Binding Path=Commands.ToggleBoldCommand}" />
    <telerikNavigation:RadMenuItem x:Name="_italicMenu" DataContext="{Binding ElementName=_rrtb}" Command="{Binding Path=Commands.ToggleItalicCommand}" Header="Italic" />
    <telerikNavigation:RadMenuItem x:Name="_underlineMenu" DataContext="{Binding ElementName=_rrtb}" Command="{Binding Path=Commands.ToggleUnderlineCommand}" Header="Underline" />
</telerikNavigation:RadMenuItem>
<telerikNavigation:RadMenuItem Header="Tools">
    <telerikNavigation:RadMenuItem x:Name="_spellCheckMenu" DataContext="{Binding ElementName=_rrtb}" Command="{Binding Path=Commands.ToggleSpellCheckingCommand}" Header="SpellCheck" />
</telerikNavigation:RadMenuItem>
accessing commands through Commands property or RadRichTextBox.

Don't hesitate to contact us if you have other questions.


Best wishes,
Boby
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
RichTextBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or