WPF Datagrid Double Click Cell MVVM Design

后端 未结 4 1895
太阳男子
太阳男子 2021-01-03 14:04

I have a WPF application that contains a datagrid. It is bound to my List object \"Orders\" shown below.

public class OrderBlock
{
  public Settings setting;         


        
4条回答
  •  太阳男子
    2021-01-03 14:30

    We can do this in two ways,

    a) By using Dependency property b) By adding System.Windows.Interactivity.dll.

    Usually I prefer second way.

    step 1: Implement ICommand interface in your view model class file.

    step 2: Define your Command,

    public ICommand DoubleClickCommand
    {
    //Do your code
    }
    

    step 2: add the above said .dll into your corresponding solution's xaml file.

    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    

    step 3: Inside the Datagrid tag, use the below code to implement InvokeCommandAction Class

    
           
                 
           
    
    

    That's it. Hope it helps you:)

提交回复
热议问题