Reputation: 41
I was customizing the menu item with a rectangle. I need to remove all the characteristics in the default menu item and add the custom rectangle into the menu. I wasn't sure what property of menu item should be override? Any help?
Upvotes: 1
Views: 734
Reputation: 17085
define a template like this:
<ControlTemplate x:Key="customMenuItem" TargetType="{x:Type MenuItem}">
<WrapPanel Background="Gray" Margin="3">
<Rectangle Fill="Black" Width="16"/>
<ContentPresenter Content="{TemplateBinding Header}"/>
</WrapPanel>
</ControlTemplate>
then use it as the Template of any menu item.
<Menu>
<MenuItem Template="{StaticResource customMenuItem}" Header="some text"/>
</Menu>
Upvotes: 2