In my WPF MVVM application each model-view contains a list of buttons. Which are valid for that user control.
private List<myButton> _buttons;
I am displaying them like this:
<ItemsControl ItemsSource="{Binding buttons}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Width="100" Height="40" VerticalAlignment="Top" Margin="5,5,5,5" Command="{Binding command}" Content="{Binding name}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Which works just fine.
Now what i would like to do is have key bindings on some of my buttons Save for example cntr + s.
How do I add key bindings for some of the buttons. From what i have found so far you would do something like this
<Window.InputBindings>
<KeyBinding Key="Z" Modifiers="Ctrl" Command="{StaticResource MyCommand1}" />
<KeyBinding Key="H" Modifiers="Alt" Command="{StaticResource MyCommand2}" />
</Window.InputBindings>
I tried adding it as a list but that didnt work at all. There must be a way of bulding the key bindings for the some of my buttons.