WPF Toolkit DataGridCell Style DataTrigger
Posted
by KrisTrip
on Stack Overflow
See other posts from Stack Overflow
or by KrisTrip
Published on 2010-05-13T21:40:16Z
Indexed on
2010/05/13
21:44 UTC
Read the original article
Hit count: 1143
I am trying to change the color of a cell to Yellow if the value has been updated in the DataGrid.
My XAML:
<toolkit:DataGrid x:Name="TheGrid"
ItemsSource="{Binding}"
IsReadOnly="False"
CanUserAddRows="False"
CanUserResizeRows="False"
AutoGenerateColumns="False"
CanUserSortColumns="False"
SelectionUnit="CellOrRowHeader"
EnableColumnVirtualization="True"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto">
<toolkit:DataGrid.CellStyle>
<Style TargetType="{x:Type toolkit:DataGridCell}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsDirty}" Value="True">
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>
</Style>
</toolkit:DataGrid.CellStyle>
</toolkit:DataGrid>
The grid is bound to a List of arrays (displaying a table of values kind of like excel would). Each value in the array is a custom object that contains an IsDirty dependency property. The IsDirty property gets set when the value is changed.
When i run this:
- change a value in column 1 = whole row goes yellow
- change a value in any other column = nothing happens
I want only the changed cell to go yellow no matter what column its in. Do you see anything wrong with my XAML?
© Stack Overflow or respective owner