WPF - How to style the menu control to remove the left margin?

后端 未结 9 1517
余生分开走
余生分开走 2021-02-04 08:41

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?

9条回答
  •  粉色の甜心
    2021-02-04 09:23

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

    
        
            
            
        
     
    

    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.

提交回复
热议问题