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

后端 未结 9 1509
余生分开走
余生分开走 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:11

    Simpal and Sort way is below: Create an ItemsPanelTemplate resource

    
        
    
    

    Add below MenuItem style to resources and you are done.

    
    

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

    
    

    also above of that for context menu you have to add

    
        
            
                    
            
        
    
    

    so it will override icon space and show case textblock.It is the simple and most easy solution.

提交回复
热议问题