I have this code and I want change background of single cell of datagrid.
in my code, change background of row.
<DataGrid x:Name="dg">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<DataTrigger Binding="{Binding Place}"
Value="true">
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
</DataGrid>
and C# code:
DataTable dt = new DataTable();
dt.Columns.Add("Time", typeof(string));
dt.Columns.Add("Place", typeof(string));
dt.Rows.Add( "23:00", "true");
dt.Rows.Add( "21:00", "true");
dt.Rows.Add( "19:00", "false");
dg.ItemsSource = dt.AsDataView();
I searched about it and this code for DataGridView:
this.dataGridView1.Rows[0].Cells[1].Style.ForeColor = System.Drawing.Color.Red;
but this not work for DataGrid of wpf.
how to change this code for DataGrid wpf?