The solutions using InputBindingBehavior did not work reliably for me. I believe this is due to the fact that the Loaded
event does not guarantee that all data bindings are evaluated. The above did work for me on one control but did not work on another simply because the key bindings that were copied onto the parent window did not have a command.
What does seem to work reliably for me is to set the focus in Xaml like this:
<UserControl x:Class="MyApp.UI.Controls.FunctionButton"
...
Focusable="True"
FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}"
>
...
</UserControl>