I'm trying to use interaction features to achieve mouse double click on standard Image control. The Image control is on UserControl and method that should handle mouse double click is on view model. The code is as following:
1) UserControl:
<ItemsControl Grid.Row="0" ItemsSource="{Binding SelectedEventPhotoList}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Name="SelectedListView">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" Columns="3"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}" Stretch="None">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<ei:CallMethodAction MethodName="DblClick" TargetObject="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Image>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
3) View model:
public void DblClick()
{
MessageBox.Show("Double click!");
}
But, it doesn't work.
UPDATE:
I did this, but it doesn't work:
1) XAML:
<ItemsControl Grid.Row="0" ItemsSource="{Binding SelectedEventPhotoList}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Name="SelectedListView">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" Columns="3"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}">
<Image.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding MouseDoubleClickCommand}"/>
</Image.InputBindings>
</Image>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
2) View model:
public DelegateCommand MouseDoubleClickCommand { get; private set; }
In constructor:
MouseDoubleClickCommand = new DelegateCommand(DblClick);
And added method:
public void DblClick()
{
MessageBox.Show("Double click!");
}