Ändern Sie die Farbe der WPF-Datagrid-Zeile
Ich habe ein WPF-Datagrid, das mit einer ObserverableCollection gefüllt ist.
Jetzt möchte ich die Zeilen je nach Zeileninhalt beim Programmstart einfärben und ob sich etwas zur Laufzeit ändert.
<code>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? } </code>
Wie kann ich zu Beginn und zur Laufzeit auf die Zeilen zugreifen?