标签:
在触发器中绑定枚举类型:
<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。
个人建议绑定枚举名。
标签:
原文地址:http://www.cnblogs.com/ligl/p/5669533.html