以下Xaml代码允许我在列表视图中使用上下文菜单,并将行详细信息作为对象发送到视图模型:
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Link This Operation"
Command="{Binding SelectedOperation}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"/>
</ContextMenu>
</ListView.ContextMenu>-->
但是我想通过双击鼠标来做同样的事情。我尝试了各种各样的。包括这个:
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding SelectedItem}"
CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=PlacementTarget.SelectedItem}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
这样可行,但对象始终为null。
有什么想法吗?
答案 0 :(得分:0)
试试这个:
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding SelectedOperation}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem}"/>
</i:EventTrigger>
</i:Interaction.Triggers>