using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using DI_Electrical.ViewModels; namespace DI_Electrical.Style { internal class SignalNoticeStyleSelector:StyleSelector { public override System.Windows.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 _Rules; public List Rules { get { if (this._Rules == null) { this._Rules = new List(); } return this._Rules; } } } }