Change WPF Datagrid Row Color
Posted
by
juergen d
on Stack Overflow
See other posts from Stack Overflow
or by juergen d
Published on 2012-04-07T17:25:40Z
Indexed on
2012/04/07
17:29 UTC
Read the original article
Hit count: 181
I have a WPF datagrid that is filled with an ObserverableCollection.
Now I want to color the rows depending on the row content at the program start and if something changes during runtime.
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?
}
How can I access the rows at start and runtime?
© Stack Overflow or respective owner