TX Text Control .NET for WPF

SpellCheckContextMenu Property

Property|Introduced in 18.0
Namespace
TXTextControl.WPF
Package
TXTextControl.TextControl.WPF.SDK as TXTextControl.WPF.dll from the private NuGet feed or Text Control Offline Packages

Description

Specifies the context menu which is used when the end-user right-clicks a misspelled word. A context menu is only available when a spell checking component has been connected with the SpellChecker property.

Syntax

public string SpellCheckContextMenu { get; set; }

Members

ValueDescription
(none)No context menu is displayed when the end-user right-clicks a misspelled word.
(Default)The TXTextControl built-in context menu is displayed when the end-user right-clicks a misspelled word.
otherThe property value must be the key of a user-defined context menu. Such a context menu must be added to the Resources dictionary of a TextControl or a parent of a TextControl in the logical element tree of the application. The resource key of the resource must be specified as property value of this property. The example below shows how to add a user-defined spell check context menu in XAML.

Examples

The following XAML example shows how to add a user-defined ContextMenu to the Resources dictionary of a TextControl:

<Window xmlns:tx="clr-namespace:TXTextControl.WPF;assembly=TXTextControl.WPF"
    xmlns:txspell="clr-namespace:TXTextControl.WPF.Proofing;assembly=TXSpell.WPF">
  <tx:TextControl Name="textControl1">
    <tx:TextControl.Resources>
      <ContextMenu x:Key="UserSpellCheckMenu">
        <MenuItem Click="MenuItem1_Clicked" Header="MenuItem1"/>
        <MenuItem Click="MenuItem2_Clicked" Header="MenuItem2"/>
        <MenuItem Click="MenuItem3_Clicked" Header="MenuItem3"/>
      </ContextMenu>
    </tx:TextControl.Resources>
  </tx:TextControl>
</Window>

The following example uses TextControl.SpellCheckContextMenu to configure spell check context menu as part of the text control workflow. The configured value is checked before the workflow continues.

textControl.SpellCheckContextMenu = "Quarterly results";
if (!string.IsNullOrWhiteSpace(textControl.SpellCheckContextMenu))
{
    Console.WriteLine($"Spell Check Context Menu: {textControl.SpellCheckContextMenu}");
}