System.Windows.Controls.MenuItem without icon area

You can achieve it by defining ItemsPanel property of MenuItem.

Create an ItemsPanelTemplate resource

<ItemsPanelTemplate x:Key="MenuItemPanelTemplate">
    <StackPanel Margin="-20,0,0,0" Background="White"/>
</ItemsPanelTemplate>

Add below MenuItem style to resources and you are done.

<Style TargetType="{x:Type MenuItem}">
   <Setter Property="ItemsPanel" Value="{StaticResource MenuItemPanelTemplate}"/>
</Style>

To apply same Style to a ContextMenu, you need to create one more Style as following-

<Style TargetType="{x:Type ContextMenu}">
   <Setter Property="ItemsPanel" Value="{StaticResource MenuItemPanelTemplate}"/>
</Style>

Leave a Comment