在wpf中只有继承自ButtonBase类的元素才具有Command属性,没有Command的用如下办法代替:
1.引入命名空间
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
2.在需要绑定Command的组件的第一层括号内使用,值得注意的是EventName类型需要自己查阅一下文档,并不会有代码提示:
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<i:InvokeCommandAction Command="{Binding ListPicBoxMouseDownCommand}"
CommandParameter="{Binding ElementName=currentTime}"/>
</i:EventTrigger>
</i:Interaction.Triggers>