iLe*_*ing 15 wpf events datagridview wpf-controls wpfdatagrid
当DataGrid的源更新时会触发哪个事件?我已经尝试过DataContextChanged和SourceUpdated,但它从未解决过.
其实我需要一个简单的事情.我想,如果有新行,请将GridView的滚动条向下滚动到底部以查看它是什么.
Nid*_*lot 26
我有同样的问题,我这样管理它
DataGrid myGrid = new DataGrid();
CollectionView myCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(myGrid.Items);
((INotifyCollectionChanged)myCollectionView).CollectionChanged += new NotifyCollectionChangedEventHandler(DataGrid_CollectionChanged);
Run Code Online (Sandbox Code Playgroud)
然后,您需要在事件处理程序中实现逻辑DataGrid_CollectionChanged.
小智 8
为ItemsSource绑定设置NotifyOnTargetUpdated = true并处理TargetUpdated事件.如果您有多个绑定,则查找DataTransferEventArgs属性以查明目标是否为ItemsSource.