WPF: How to bind a command to the ListBoxItem using MVVM?

Unfortunately, only ButtonBase derived controls have the possibility for binding ICommand objects to their Command properties (for the Click event). However, you can use an API provided by Blend to map an event (like in your case MouseDoubleClick on the ListBox) to an ICommand object. <ListBox> <i:Interaction.Triggers> <i:EventTrigger EventName=”MouseDoubleClick”> <i:InvokeCommandAction Command=”{Binding YourCommand}”/> </i:EventTrigger> </i:Interaction.Triggers> </ListBox> … Read more

How to bind Close command to a button

All it takes is a bit of XAML… <Window x:Class=”WCSamples.Window1″ xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”> <Window.CommandBindings> <CommandBinding Command=”ApplicationCommands.Close” Executed=”CloseCommandHandler”/> </Window.CommandBindings> <StackPanel Name=”MainStackPanel”> <Button Command=”ApplicationCommands.Close” Content=”Close Window” /> </StackPanel> </Window> And a bit of C#… private void CloseCommandHandler(object sender, ExecutedRoutedEventArgs e) { this.Close(); } (adapted from this MSDN article)