Context Menu items command binding WPF using MVVM

后端 未结 5 567
眼角桃花
眼角桃花 2021-01-01 04:56

I know this question has been asked many times in different ways in many websites and also in StackOverFlow but all the answers I found are not helping me ot to be precise I

5条回答
  •  遥遥无期
    2021-01-01 05:37

    You have two options.
    Note: the code samples I added here a similar, but not same as your samples.

    Move the definition of the ContextMenu inside the DataGrid defintion as follows:

    
       
           
               
               
               
           
       
    
    

    Or better add a CommandReference to your Resources and set the Command in the MenuItem to a StaticResource as follows:

    
        
    
        
            
            
            
        
    
        
    
    
    
    
    

提交回复
热议问题