我有一个Enum:
namespace LibiqCommonStructures
{
using System;
public enum ItemStatusType
{
NotImplemented,
New,
Processed,
Missing,
NotUsed,
Failed
}
}
<igWPF:XamDataGrid DataSource="{Binding Path=Images}" ActiveDataItem="{Binding SelectedItem}" MaxHeight="300">
<igWPF:XamDataGrid.Resources>
<Style TargetType="{x:Type igWPF:DataRecordCellArea}" BasedOn="{StaticResource {x:Type igWPF:DataRecordCellArea}}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.ItemStatus}" Value="{x:Static libIq:ItemStatusType.Missing}">
<Setter Property="Background" Value="Tomato"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</igWPF:XamDataGrid.Resources>
<igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:FieldLayoutSettings SelectionTypeRecord="Single" AutoGenerateFields="False" AllowDelete="False"/>
</igWPF:XamDataGrid.FieldLayoutSettings>
<igWPF:XamDataGrid.FieldSettings >
<igWPF:FieldSettings Width="Auto" AllowEdit="False" />
</igWPF:XamDataGrid.FieldSettings>
<igWPF:XamDataGrid.FieldLayouts>
当枚举为ItemStatusType.Missing
时,我想更改行的背景颜色我可以看到错过了绑定但行的颜色没有改变。 我的 x:static 可能有问题吗?
答案 0 :(得分:2)
将枚举字符串放在Value中。它会起作用:
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.ItemStatus}" Value="Missing">
<Setter Property="Background" Value="Tomato"></Setter>
</DataTrigger>