0

I am wondering if it is possible to create double click event on autogenerated data grid in mvvm. So far my Data grid looks like:

<DataGrid AutoGenerateColumns="True" AutoGeneratingColumn="OnAutoGeneratingColumn"
     CanUserSortColumns="False"
     GridLinesVisibility="None"
     CanUserAddRows="False"
     SelectionUnit="Cell"

     ItemsSource="{Binding ValuesView}"
     CellStyle="{StaticResource CellStyle}"
     CurrentCell="{Binding SelectedValue, Mode=TwoWay}" />

So in quick description Item source is a DataTable object, and I managed to bind single click to

 CurrentCell="{Binding SelectedValue, Mode=TwoWay}" 

property, and it works, on command so in view model I am reciving:

    private DataGridCellInfo selectedValue;
    public DataGridCellInfo SelectedValue
    {
        get => selectedValue;
        set
        {
            selectedValue= value;
            OnPropertyChanged();

            // some operation I am making on DataGridCellInfo 
        }
    }

Now Is it possible to without changing View model code, get same result on double click instead of single?

Wojciech Szabowicz
  • 3,646
  • 5
  • 43
  • 87
  • Possible duplicate of [WPF ListView: Attaching a double-click (on an item) event](https://stackoverflow.com/questions/728205/wpf-listview-attaching-a-double-click-on-an-item-event) – Paul Kertscher Apr 11 '18 at 11:46
  • It's not a duplicate. There are event handlers in that link and this is a viewmodel. No event handler. – Andy Apr 11 '18 at 14:51

0 Answers0