WPF DataGrid has RowEditEnding but no RowEditEnded

后端 未结 5 1227
生来不讨喜
生来不讨喜 2021-02-19 20:04

I\'ve bound an ObservableCollection to a DataGrid. When I change values in the DataGrid, the RowEditEnding event is raised. But the e.Row.Item is the object before editing, so y

5条回答
  •  你的背包
    2021-02-19 20:49

    This solution seems simple enough. Referred from msdn forum.

    private void dgEmployees_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
    {           
        Action action = delegate
                      {
                         Employee emp = e.Row.Item as Employee;
                        //do something nice to the employee                
                       };
        Dispatcher.BeginInvoke(action, System.Windows.Threading.DispatcherPriority.Background);
    }
    

提交回复
热议问题