我有一个带有EventTrigger MouseDoubleClick的列表框。
此不起作用:EventName =" MouseDoubleClick"
有效:EventName =" MouseLeftButtonUp"
这是视图
<ListBox x:Name="MyListBox" />
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<command:EventToCommand Command="{Binding UserSelectionCommand}"
CommandParameter="{Binding SelectedItem, ElementName=MyListBox}"
/>
</i:EventTrigger>
</i:Interaction.Triggers>
在ViewModel中
public RelayCommand<string> UserSelectionCommand
{get; private set;}
UserSelectionCommand = new RelayCommand<string>(ShowSelectedItem);
private void ShowSelectedItem(string selectedData)
{ .. }
答案 0 :(得分:0)
结束ListBox应该在Interaction.Triggers之后,而不是之前。
<ListBox>
<Interaction.Triggers>
..
<Interaction.Triggers>
</ListBox>