首页 > 其他分享 >WPF ListBox ContextMenu MenuItem Command CommandParameter Path PlacementTarget

WPF ListBox ContextMenu MenuItem Command CommandParameter Path PlacementTarget

时间:2024-09-18 21:47:04浏览次数:1  
标签:PlacementTarget CommandParameter ContextMenu Command MenuItem Path

<ListBox.ContextMenu>
    <ContextMenu>
        <MenuItem Header="Export NewtonSoftJson"  
                  FontSize="50" 
                  Foreground="Red"
                  Command="{Binding ExportNewtonJsonCmd}"
                  CommandParameter="{Binding RelativeSource={RelativeSource 
                  Mode=FindAncestor,AncestorType={x:Type ContextMenu}},Path=PlacementTarget}"/>
        <MenuItem Header="Export BinaryFormatter"
                  FontSize="50"
                  Foreground="Red"
                  Command="{Binding ExportBinaryFormatterCmd}"
                  CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
            AncestorType={x:Type ContextMenu}},Path=PlacementTarget}"/>
    </ContextMenu>
</ListBox.ContextMenu>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

标签:PlacementTarget,CommandParameter,ContextMenu,Command,MenuItem,Path
From: https://www.cnblogs.com/Fred1987/p/18419388

相关文章