0
A
回答
0
見討論here,而這個解決方案:
private void OnRowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
DataGrid dataGrid = sender as DataGrid;
if (e.EditAction == DataGridEditAction.Commit) {
ListCollectionView view = CollectionViewSource.GetDefaultView(dataGrid.ItemsSource) as ListCollectionView;
if (view.IsAddingNew || view.IsEditingItem) {
this.Dispatcher.BeginInvoke(new DispatcherOperationCallback(param =>
{
// This callback will be called after the CollectionView
// has pushed the changes back to the DataGrid.ItemSource.
// Write code here to save the data to the database.
return null;
}), DispatcherPriority.Background, new object[] { null });
}
}
}
相關問題
- 1. WPF中DataGrid的CellValueChanged事件?
- 2. 在DataGrid中捕獲DoubleClick
- 3. wpf datagrid點擊事件
- 4. WPF捕獲文本框onBlur事件
- 5. WPF子類捕獲按鍵事件
- 6. WPF Datagrid:取消排序事件(WPF Bug?)
- 7. 在WPF中的應用程序級別捕獲關鍵事件
- 8. 在wpf應用程序中捕獲Windows關機事件
- 9. 在WPF列表框項目模板中捕獲事件
- 10. WPF - 從不在頂端的控件捕獲事件
- 11. 捕獲由事件
- 12. Brightcove事件捕獲
- 13. RAS事件捕獲
- 14. 捕獲MediaPlayerPlaying事件
- 15. 選擇所有事件:WPF Datagrid
- 16. WPF Datagrid行編輯「已結束」事件
- 17. PreviewMouseRightButtonDown路由事件和WPF DataGrid
- 18. WPF的DataGrid SelectedCellsChanged事件觸發兩次
- 19. WPF的DataGrid編輯單元事件
- 20. WPF Datagrid OnPropertyChanged導致SelectionChanged事件
- 21. Wpf工具包datagrid DataGridCheckBoxColumn on_click事件:
- 22. 捕獲Windows 10中的屏幕鎖定事件(WPF)
- 23. 在nativescript中捕獲SMS事件
- 24. 在Python中捕獲關機事件
- 25. 在WIndow服務中捕獲KeyPress事件
- 26. 在C(linux)中捕獲鼠標事件
- 27. 在c#中捕獲ActiveDirectory「addUser」事件?
- 28. 在gtk中捕獲滾動事件#
- 29. 在NSDocument中捕獲窗口事件
- 30. 在IE Mobile中捕獲javascript事件