mvvm里面 mouse事件的绑定

首先要用到

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

这个dll

然后

<i:Interaction.Triggers>
  <i:EventTrigger EventName="MouseLeftButtonDown">
<i:InvokeCommandAction Command="{Binding DataContext.ProductDetailCommand,ElementName=root}"/>
</i:EventTrigger>
</i:Interaction.Triggers>

本来command 是直接绑定command 的

但由于是在 listbox 的itemtempalte 的datatempalte里面,

listbox 的itemsource 是确定的 所以 listbox里面的item 的source 不会是viewmodel, 还是 当前页面通过当前页面传到

posted on 2012-06-27 19:16  GIS-MAN  阅读(563)  评论(0编辑  收藏  举报

导航