Binding MenuItem.IsChecked to RichTextBox.SpellCheck.IsEnabled
-
Hi, I have the following deceleration of a rich text box:
<RichTextBox
x:Key="rtfBox"
SpellCheck.IsEnabled = "False"
ContextMenuService.ShowOnDisabled="True"
ContextMenu="{StaticResource rtfBoxContextMenu}">
</RichTextBox>And the context menu is defined as a resource on the same xaml as follows:
<ContextMenu x:Key="rtfBoxContextMenu">
<MenuItem Command="Copy"/>
<MenuItem Command="Cut"/>
<MenuItem Command="Paste"/>
<Separator/>
<MenuItem Command="My:MyCommands.ToggleSpellChecker" IsCheckable="true"/>
</ContextMenu>I would like to bind the check box of the menu item to the state of the spellcheck isenabled property. Please help. What minimal xaml/code is needed for that? 10x
-
Hi, I have the following deceleration of a rich text box:
<RichTextBox
x:Key="rtfBox"
SpellCheck.IsEnabled = "False"
ContextMenuService.ShowOnDisabled="True"
ContextMenu="{StaticResource rtfBoxContextMenu}">
</RichTextBox>And the context menu is defined as a resource on the same xaml as follows:
<ContextMenu x:Key="rtfBoxContextMenu">
<MenuItem Command="Copy"/>
<MenuItem Command="Cut"/>
<MenuItem Command="Paste"/>
<Separator/>
<MenuItem Command="My:MyCommands.ToggleSpellChecker" IsCheckable="true"/>
</ContextMenu>I would like to bind the check box of the menu item to the state of the spellcheck isenabled property. Please help. What minimal xaml/code is needed for that? 10x
You could name the CheckBoxMenuItem and bind it via property path. Like
<ContextMenu x:Key="rtfBoxContextMenu">
<MenuItem Command="Copy"/>
<MenuItem Command="Cut"/>
<MenuItem Command="Paste"/>
<Separator/>
<MenuItem Command="My:MyCommands.ToggleSpellChecker" IsCheckable="true" Name="menuItemCheckBox"/>
</ContextMenu><RichTextBox
x:Key="rtfBox"
SpellCheck.IsEnabled = "{Binding Source={StaticResource rtfBoxContextMenu}, Path=menuItemCheckBox}"
ContextMenuService.ShowOnDisabled="True"
ContextMenu="{StaticResource rtfBoxContextMenu}">
</RichTextBox>