WPF: How can you add a new menuitem to a menu at runtime?

后端 未结 5 614
天命终不由人
天命终不由人 2020-12-09 03:44

I have a simple WPF application with a menu. I need to add menu items dynamically at runtime. When I simply create a new menu item, and add it onto its parent MenuItem, it

5条回答
  •  一个人的身影
    2020-12-09 04:06

    I ran into the same problem. In my case the problem was that in the XAML the was directly contained in a . Once I put the inside a

    it started working. So:

    
       
       
       
    

    is bad

    
        
            
            
        
       
    

    is good

提交回复
热议问题