WPF MVVM模式开发中列表控件内的按钮触发不了command事件

处理方法:

<Button Content="删除" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListView}, Path=DataContext.DeleteCommand}" CommandParameter="{Binding ID,Mode=TwoWay}"/>


<Button Content="删除" Width="40" Margin="3,0,0,0" Command="{Binding ElementName=父节点名称,Path=DataContext.DeleteCommand}" CommandParameter="{Binding ID,Mode=TwoWay}"/>

 

<Buttonx:Name="button" Content="View" Margin="5" DataContext="{StaticResource DataContext}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding command操作}" CommandParameter="{Binding ElementName=列表名称, Path=SelectedItem}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>

 
posted @ 2013-08-02 23:13  骑猪上学  阅读(1279)  评论(0编辑  收藏  举报