SpellingExtensions Class
A base class for spell check extension methods.
Namespace: DevExpress.Xpf.SpellChecker
Assembly: DevExpress.Xpf.SpellChecker.v19.2.dll
Declaration
public static class SpellingExtensions
Public Module SpellingExtensions
The SpellingExtensions class provides extensiton methods used to retrieve SpellChecker error commands.
The GetErrorOperationCommands method creates a list of SpellChecker commands. The list depends on the type of misspelling and current spellchecker operation mode.
Use the GetSpellCheckError method to invoke a custom context menu for misspelled words, as shown below:
<RichTextBox x:Name="richTextBox" PreviewMouseRightButtonUp="RichTextBox_PreviewMouseRightButtonUp">
<RichTextBox.ContextMenu>
<ContextMenu ItemsSource="{Binding Path=MenuItems}"/>
</RichTextBox.ContextMenu>
<dxmvvm:Interaction.Behaviors>
<dxspch:DXSpellChecker Culture="en-US" CheckAsYouType="True"/>
</dxmvvm:Interaction.Behaviors>
</RichTextBox>
void RichTextBox_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
MenuItems.Clear();
var commands = this.richTextBox.GetErrorOperationCommands(e.GetPosition(this.richTextBox));
foreach (var command in commands)
{
var menuItem = new MenuItem();
menuItem.Header = command.Caption;
menuItem.Click += (s, args) => command.DoCommand();
menuItem.IsEnabled = command.Enabled;
MenuItems.Add(menuItem);
}
if (MenuItems.Count == 0)
MenuItems.Add(new MenuItem() { Header = "No Error", IsEnabled = false });
}
Private Sub RichTextBox_PreviewMouseRightButtonUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
MenuItems.Clear()
Dim commands = Me.richTextBox.GetErrorOperationCommands(e.GetPosition(Me.richTextBox))
For Each command In commands
Dim menuItem = New MenuItem()
menuItem.Header = command.Caption
AddHandler menuItem.Click, Sub(s, args) command.DoCommand()
menuItem.IsEnabled = command.Enabled
MenuItems.Add(menuItem)
Next command
If MenuItems.Count = 0 Then
MenuItems.Add(New MenuItem() With {.Header = "No Error", .IsEnabled = False})
End If
See Also