I am having trouble binding a Command that is generated up the UI tree to a control. The following example illustrates my point, the CommandBinding
in Grid
does not act on the InputBindings
in Window. Maybe I do not understand the point of commands, but I would like to have a nice solution for child controls to act on user input on the Window (any control on the Window).
<Window x:Class="SilverFit.Menu.Wpf.WpfWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.InputBindings>
<KeyBinding Command="Close" Key="Escape"/>
<MouseBinding Command="Close" MouseAction="RightClick" />
</Window.InputBindings>
<Grid Name="grid">
<Grid.CommandBindings>
<CommandBinding Command="Close" Executed="Close"/>
</Grid.CommandBindings>
</Grid>
</Window>