Bind DoubleClick Command from DataGrid Row to VM

后端 未结 4 810
悲&欢浪女
悲&欢浪女 2020-12-25 13:37

I have a Datagrid and don\'t like my workaround to fire a double click command on my viewmodel for the clicked (aka selected) row.

View:

   

        
4条回答
  •  执笔经年
    2020-12-25 13:49

    Why don't you simply use the CommandParameter?

    
    
        
            
                
            
        
        ...
    
    

    Your command is something like this:

    public ICommand MouseDoubleClickCommand
    {
        get
        {
            if (mouseDoubleClickCommand == null)
            {
                mouseDoubleClickCommand = new RelayCommand(
                    item =>
                    {
                        var selectedItem = item;
                    });
            }
    
            return mouseDoubleClickCommand;
        }
    }
    

    EDIT: I now use this instead of Interaction.Triggers:

    
        
    
    

提交回复
热议问题