Best way to set a MenuItem's sub-menu height?

前端 未结 1 1735
故里飘歌
故里飘歌 2021-01-25 01:46

I currently have a menuitem (part of a context menu), with about ~35 menu items. Because of this, it causes the sub-menu to be huge. Even though I have scrolling ability, I woul

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-25 02:07

    Unfortunately, WPF does not allow this to be modified by properties. You will have to modify the default ControlTemplate.

    EDIT: I revised the blog entry on that here

    Here is a sample (notice the addition of "MaxHeight" on "SubMenuScrollViewer"):

    
        
            
                
                    
                        
                            
                        
                        
                    
                
            
        
    
    

    This is just to override the Aero theme. As you can see there is a lot of XAML for the MenuItem, so it's not graceful. Just make a separate ResourceDictionary to keep things tidy.

    0 讨论(0)
提交回复
热议问题