I try to start ICommand when the user double-clicks on a list item. Also, I'm trying to do this using the MVVM pattern.
In this XAML, pressing the p key works fine. When I double-click on a list box, the command never starts. I set a breakpoint to confirm that "PlayVideoCommand" is not called with a double click. Am I missing something or do I need to use Setter (which I am not familiar with)?
<ListBox Name="SmallVideoPreviews" Grid.Column="1" MaxHeight="965" ItemsSource="{Binding BrowseVideos}" ItemTemplate="{StaticResource BrowseTemplate}"> <ListBox.InputBindings> <KeyBinding Key="p" Command="{Binding PlayVideoCommand}" CommandParameter="{Binding ElementName=SmallVideoPreviews, Path=SelectedItem}"/> <MouseBinding Gesture="LeftDoubleClick" Command="{Binding PlayVideoCommand}" CommandParameter="{Binding ElementName=SmallVideoPreviews, Path=SelectedItem}"/> </ListBox.InputBindings> </ListBox>
Both double-clicks and "p" must execute the same command. When using the mouse, I see that listboxitem is selected. I have a hunch that the MouseBinding Command property is not a dependency property, but I donβt know how to confirm this.
James
source share