The Situation:
I have some Editing commands in WPF window, and a close command (Application.CloseCommand) and have some bindings like this
View:
<Window.CommandBindings>
<CommandBinding Command="ApplicationCommands.Close"
Executed="CloseCommandBinding_Executed"/>
<CommandBinding Command="EditingCommands.ToggleBold"
Executed="EditingCommand_Executed"></CommandBinding>
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="Esc" Command="ApplicationCommands.Close"></KeyBinding>
</Window.InputBindings>
.. *Some panel and grid stuff and more things* ..
<RichTextBox Name="RTBPopup">
<RichTextBox.InputBindings>
<KeyBinding Key="Esc" Command="ApplicationCommands.Close"></KeyBinding>
</RichTextBox.InputBindings>
</RichTextBox>
.. *Some panel and grid stuff and more things* ..
<ToggleButton x:Name="btnToggleBold" CommandManager.Executed="EditingCommand_Executed" Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=RTBPopup}">B</ToggleButton>
Now:
If I press escape in RTBPopup (Richtextbox) the command gets executed and the debugger hits the breakpoint set on CloseCommandBinding_Executed method
but
when I click on toggle button for bold or press control + B, the EditingCommand_Executed is not getting hit by debugger (not getting executed)
What else I have tried:
<ToggleButton.CommandBindings>
<CommandBinding Command="EditingCommands.ToggleBold" Executed="EditingCommand_Executed"></CommandBinding>
</ToggleButton.CommandBindings>