Wpf Autogenereting DataGrid在mvvm中双击事件

时间:2018-04-11 11:36:13

标签: c# wpf xaml

我想知道是否可以在mvvm中的自动生成数据网格上创建双击事件。到目前为止,我的数据网格看起来像:

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

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

因此,在快速描述中,Item source是一个DataTable对象,我设法将单击绑定到

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

属性,并且它在命令上工作,所以在视图模型中我正在恢复:

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

            // some operation I am making on DataGridCellInfo 
        }
    }

现在是否可以在不更改View模型代码的情况下,在双击而不是单击时获得相同的结果?

0 个答案:

没有答案