【问题标题】:data trigger with enum带枚举的数据触发器
【发布时间】:2014-07-26 03:42:12
【问题描述】:

我有一个枚举:

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 有问题?

【问题讨论】:

    标签: wpf wpf-controls infragistics


    【解决方案1】:

    只需将枚举字符串放入 Value 中即可。它会起作用的:

           <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem.ItemStatus}" Value="Missing">
                 <Setter Property="Background" Value="Tomato"></Setter>
            </DataTrigger>
    

    【讨论】:

    • 你在 ItemStatus 上提高 PropertyChanged 吗?
    • 是的,据我所知,这不是在 datatrigger stackoverflow.com/questions/13917033/… 中使用枚举的方式@
    • 有时可以,有时不行,可能是虚拟化问题?
    猜你喜欢
    • 2012-12-04
    • 2017-07-28
    • 2021-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-17
    • 2013-10-24
    相关资源
    最近更新 更多