009_DI-Elec/newFront/c#前端/SWS.CustomControl/Selector/SignalNoticeStyleSelector.cs

42 lines
1.1 KiB
C#
Raw Normal View History

2025-08-15 15:33:20 +08:00
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using SWS.Model;
namespace SWS.CustomControl
{
public class SignalNoticeStyleSelector:StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
SignalNotice conditionValue = item as SignalNotice;
string value = conditionValue.CheckFLG.ToString();
foreach (ConditionalStyleRule rule in this.Rules)
{
//值相同则返回当前样式
if (Equals(rule.Value, value))
{
return rule.Style;
}
}
return base.SelectStyle(item, container);
}
List<ConditionalStyleRule> _Rules;
public List<ConditionalStyleRule> Rules
{
get
{
if (this._Rules == null)
{
this._Rules = new List<ConditionalStyleRule>();
}
return this._Rules;
}
}
}
}