Hi,
Assume I have a window and XamMaskedEditor within. I want the window to process my own custom command when user presses F2 button.
The problem is that when XamMaskedEditor is focused , each F2 key press is handled inside the control and my custom command is not executed.
Any ideas how to make it work? I need a way to disable F2 processing in XamMaskedEditor.
Hello,
Fortunately, WPF provides routed event handling. This means you can provide a Preview event handler which will intercept an event before it tunnels down to the child element which the event is intended for. There is a Handled property in the event arguments which you can set to true to stop the event from continuing on its trek. Whatever event you are using for handle the F2 key action, look for a Preview version of the event and try handling that.
Thanks,
Hi Curtis,
thanks for reply!
The problem is I don't really handle KeyUp or KeyDown events, I'm using CommandBinding with KeyGesture set to specific functional key.
So I have smth. like this:
<UserControl.CommandBindings>
<CommandBinding Command="{x:Static local:Commands.AcceptPaymentCmd}"
CanExecute="Command_CanExecuteWhenTransactionInProgress" Executed="AcceptPayment_Executed"/>
Assume AcceptPaymentCmd has F2 input gesture and the XamMaskedEditor is focused currently. User presses F2 and expects the AcceptPaymentCmd to be executed. But instead, the command inside XamMaskedEditor is executed.
Is the only workaround for me will be to subscribe to Preview event and manually call command execution?
It is not a good way in my case.