WPF ListboxItem and ContextMenu

后端 未结 3 1497
感动是毒
感动是毒 2021-01-02 17:29

I have code like this:


    
        

        
3条回答
  •  灰色年华
    2021-01-02 18:05

    Firstly, something strange is that you are trying to set Command and the Click event. You should set one or the other. Maybe the fact the action is disabled is because you are setting a Command with a value of CanExecute = false;

    Instead of writing a DataTemplate, you can try to set the ItemContainerStyle for the ListBoxItem like this:

    
        
            
        
    
    

    Here I directly set the ContextMenu of the ListBoxItem instance so it will display the menu on the right control.

提交回复
热议问题