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 @ 2016-07-15 21:36  ligl007  阅读(1243)  评论(0编辑  收藏  举报