![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 <Button CommandParameter="{Binding}" 2 Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type pagesView:OutputPage}}}" 3 Command = "{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type pagesView:OutputPage}}, Path=DataContext.EditOutputCommand}"> 4 <Button.ContextMenu> 5 <ContextMenu> 6 <MenuItem Header="削除" 7 CommandParameter="{Binding}" 8 Command="{Binding Path=PlacementTarget.Tag.DataContext.DeleteCurrentLineCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> 9 </ContextMenu> 10 </Button.ContextMenu> 11 </Button>
button.contextmenu的command 失效;
参考地址:http://stackoverflow.com/questions/9994241/mvvm-binding-command-to-contextmenu-item