Does a RoutedUICommand
automatically reach the currently focused control (provided the control has the right command binding)? E.g.:
<Button Focusable="False" Command="ApplicationCommands.Open" Content="Open" />
<UserControl Name="ctl" Focusable="True" IsTabStop="True">
<UserControl.CommandBindings>
<CommandBinding Command="ApplicationCommands.Open" CanExecute="CanOpen" Executed="OpenExecuted"/>
<!-- ... -->
</UserControl.CommandBindings>
</UserControl>
Will ApplicationCommands.Open
reach UserControl
when it has focus, without declaring explicit CommandTarget
on Button
? Thank you.
EDITED
I tried it and it doesn't seem to be the case, at least not forUserControl
.It DOES indeed, when you specify
FocusManager.IsFocusScope="true"
on the source of the command. A similar question answered.XAML:
C#: