How can I bind an ObservableCollection of ViewModels to a MenuItem?

前端 未结 4 2030
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 02:51

When I bind Menu Items with an ObservableCollection, only the \"inner\" area of the MenuItem is clickable:

alt text http://tanguay.info/web/external/mvvmMenuItems.pn

4条回答
  •  别那么骄傲
    2020-12-13 03:27

    Don't put the MenuItem in the DataTemplate. The DataTemplate defines the content of the MenuItem. Instead, specify extraneous properties for the MenuItem via the ItemContainerStyle:

    
        
            
        
        
    
    

    Also, take a look at HierarchicalDataTemplates.

提交回复
热议问题