DataGrid catch cell value changed event with a single click on UpdateSourceTrigger = SourceUpdated

前端 未结 3 1058
灰色年华
灰色年华 2021-01-11 19:19

I\'m struggling to catch an event with a DataGrid. What I want to achieve is that when the user clicks ONCE on a checkbox of a datagrid cell, an event fires and I can get th

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 19:49

    1) In your DataGrid register for TargetUpdated event .

    2) Specify a Column , and ideally set AutoGenerateColumns=False .

    3) In your Binding flag the NotifyOnTargetUpdated property (your target is your checkbox).

    4) In your Binding UpdateSourceTrigger=PropertyChanged and Mode=TwoWay (not the default behavior of the DataGrid).

    XAML :

     
        
                                    
        
    
    

    in CS: (where you might wan't to handle that event.)

       private void DataGrid_TargetUpdated(object sender, DataTransferEventArgs e)
       {
             // Do what ever...
       }  
    

提交回复
热议问题