DataTrigger 绑定枚举

在触发器中绑定枚举类型:

复制代码
                        <ControlTemplate.Triggers>
                            <DataTrigger Binding="{Binding CheckStateEnum}" Value="WaitCheck">
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemNotCheckColor}"></Setter>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding CheckStateEnum}" Value="Current">
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemSelectedColor}"></Setter>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding CheckStateEnum}" Value="AlreadyCheck">
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ListViewItemCheckColor}"></Setter>
                            </DataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
复制代码

 

复制代码
    /// <summary>
    /// 检查状态
    /// </summary>
    public enum CheckState
    {
        /// <summary>
        /// 待检
        /// </summary>
        WaitCheck,
        /// <summary>
        /// 当前检查血管
        /// </summary>
        Current,
        /// <summary>
        /// 已检查
        /// </summary>
        AlreadyCheck,
    }
复制代码

DataTrigger 绑定Value也可以是具体的枚举值 ex: 0   1  2。

个人建议绑定枚举名。

posted @   ligl007  阅读(1246)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示