Tôi có một DataGrid WPF được điền bằng một ObserverableCollection.Thay đổi Màu dữ liệu Dòng dữ liệu WPF
Bây giờ tôi muốn tô màu các hàng tùy thuộc vào nội dung hàng tại thời điểm bắt đầu chương trình và nếu có điều gì đó thay đổi trong thời gian chạy.
System.Windows.Controls.DataGrid areaDataGrid = ...;
ObservableCollection<Area> areas;
//adding items to areas collection
areaDataGrid.ItemsSource = areas;
areaDataGrid.Rows <-- Property not available. how to access rows here?
CollectionView myCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(areaDataGrid.Items);
((INotifyCollectionChanged)myCollectionView).CollectionChanged += new NotifyCollectionChangedEventHandler(areaDataGrid_Changed);
...
void areaDataGrid_Changed(object sender, NotifyCollectionChangedEventArgs e)
{
//how to access changed row here?
}
Tôi làm cách nào để truy cập vào các hàng khi bắt đầu và thời gian chạy?