WPF ListBox ContextMenu MenuItem Command CommandParameter Path PlacementTarget
<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>