DataGrid's ROW & CELL color Changing is one of most important part in our development. if you want to change Data grid specific cell Background just like:
use the xaml code for "Remaining Day" column in your Datagrid.
Enjoy...
use the xaml code for "Remaining Day" column in your Datagrid.
<DataGridTemplateColumn Header="Remaining Day" Width="150">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border x:Name="brdBroder" VerticalAlignment="Stretch" Margin="1">
<TextBlock Text="{Binding RemainLeave}" Margin="3,1" x:Name="txtTextBlock"/>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RemainLeave}" Value="0">
<Setter TargetName="brdBroder" Property="Background" Value="Green"/>
<Setter TargetName="txtTextBlock" Property="Foreground" Value="White"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Enjoy...
Comments
Post a Comment