Q085. XamDataGrid で特定データの前景色を変更するには?
A.DataRecordCellArea のスタイルを編集します。
以下のサンプルでは、department 列が「事務」のレコードの前景色を赤に設定してます。
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igDP="http://infragistics.com/DataPresenter" xmlns:igWindows="http://infragistics.com/Windows" Title="MainWindow" Height="320" Width="540" WindowStartupLocation="CenterScreen" > <Window.Resources> <Style TargetType="{x:Type igDP:DataRecordCellArea}" > <Setter Property="Foreground" Value="Black" /> <Style.Triggers> <!-- DataTrigger で department 列が「事務」の場合、前景色を赤に設定します --> <DataTrigger Binding="{Binding Path=Cells[department].Value}" Value="事務"> <Setter Property="Foreground" Value="Red" /> </DataTrigger> </Style.Triggers> </Style> </Window.Resources> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="8" /> <ColumnDefinition /> <ColumnDefinition Width="8" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="8" /> <RowDefinition Height="30" /> <RowDefinition Height="4" /> <RowDefinition /> <RowDefinition Height="8" /> </Grid.RowDefinitions> <igDP:XamDataGrid Name="xamDataGrid1" Grid.Column="1" Grid.Row="3" BindToSampleData="True" /> </Grid> </Window>