views:

129

answers:

1

I have added a default menu control to my user control. I need to style the menu to remove the left margin containing the space for the icon or checkbox. How can I do this?

XAML:

<Menu>
    <MenuItem Header="MyMenu" FontSize="10">
        <MenuItem Header="Options..." />
        <MenuItem Header="About" />
    </MenuItem>
</Menu>  

It currently renders like any other Menu control out of the box:

alt text

I don't want the margin or column to the left of the menu items. This is typically used for icons etc.

+1  A: 

It's not very straight forward, but you need to create a MenuItemStyle, easiest through Expression Blend:

<Menu>
    <MenuItem Header="MyMenu" Style="{DynamicResource MenuItemStyle1}">
        <MenuItem Header="Options..." />
        <MenuItem Header="About" />
    </MenuItem>
</Menu> 

It creates an extremely verbose set of templates and styles, and you need to edit the menu item to remove the fixed width first column of the grid, then in the SubMenuBorder ContentControl template, remove the rectangles which form the background shading. I've attached a sample project with margins removed. Download sample project here.

felixthehat
Thanks. It'll be a few days but I will check this out.
BrianLy