我正在尝试在用户双击列表框项目时启动ICommand。同时,我正在尝试使用MVVM模式来实现这一点。
在这个XAML中,按键“p”完美地工作。当我双击列表框时,命令从未启动。我设置了一个断点以确认“PlayVideoCommand”没有被双击调用。我是否漏掉了什么,或者我必须使用Setter(我不熟悉它)?
<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"键应该执行相同的命令。当使用鼠标时,我可以看到列表框项目被选中。我有一种预感,MouseBinding Command属性不是一个依赖属性,但我不知道如何确认。