Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF datagrid changing text color based on some criteria

$
0
0

Hi All,

          I have design a C# datagrid using wPF. I can now add my data into the datagrid well. Below is my xaml settings for my datagrid. My only challenge is that if any of the column values is with **Error I want the text to be red and bold. How to achieve this?

<TabItem Header=" Records">                    <DataGrid x:Name="gridRE"                          RenderOptions.ClearTypeHint="Enabled"                          TextOptions.TextFormattingMode="Display"                          Margin="18,17,0,0"                          SelectionUnit="FullRow"                                     AutoGenerateColumns="False"           HorizontalAlignment="Left"  VerticalAlignment="Top" Height="350" Width="972" >                        <DataGrid.Columns>                            <DataGridTextColumn Header="RecordID" Binding="{Binding RowID}"  />                            <DataGridTextColumn Header="CName" Binding="{Binding CName}"  />                            <DataGridTextColumn Header="BRN" Binding="{Binding CBRN}" />                                                       <DataGridTextColumn Header="FCD" Binding="{Binding FileCreationDate}" />                                                   </DataGrid.Columns>                        <DataGrid.CellStyle>                            <Style TargetType="{x:Type DataGridCell}">                                <Setter Property="Foreground" Value="{Binding Report}" />                                <Style.Triggers>                                    <Trigger Property="IsSelected" Value="True">                                        <Setter Property="Background" Value="Pink"/>                                        <Setter Property="Foreground" Value="White"/>                                    </Trigger>                                </Style.Triggers>                            </Style>                        </DataGrid.CellStyle>                    </DataGrid>                </TabItem>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>