我试图推出一个ICommand当一个列表框项目的用户双击。 另外,我想这个使用MVVM模式做。
在此XAML中,按键“P”完美的作品。 当我双击列表框,命令永远不会发生。 我设置了一个破发点,以确认“PlayVideoCommand”不与双击调用。 我缺少的东西或我使用二传手(这我不熟悉的)?
<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>
无论双击和“p”应执行相同的命令。 当使用鼠标,我可以看到ListBoxItem中被选择。 我有一种预感,在MouseBinding命令属性不是依赖财产,但我不知道如何来证实这一点。