MVVMLIGHT:MouseDoubleClick不起作用

时间:2014-04-04 14:38:30

标签: c# wpf mvvm-light

我有一个带有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)
{ .. }

1 个答案:

答案 0 :(得分:0)

结束ListBox应该在Interaction.Triggers之后,而不是之前。

<ListBox> 
 <Interaction.Triggers>
 ..
<Interaction.Triggers>
</ListBox>