Fork me on GitHub

MVVM下鼠标右键菜单命令通过桥接的方式绑定上下文

<Grid Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}">
 <Grid.ContextMenu>
  <ContextMenu>
    <MenuItem
      Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ContextMenu}}, Path=PlacementTarget.Tag.DataContext.ExtractToSubGraphCommand}"
      CommandParameter="{Binding}"
      Header="提取" />
  </ContextMenu>
 </Grid.ContextMenu>
</Grid>
posted @ 2023-05-08 09:57  猫叔Vincent  阅读(18)  评论(0编辑  收藏  举报