using NaiBa.Util.Extension; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; using System.Windows.Media; namespace _29WxOrderWpf.Converters { public class FlagColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value.ParseToInt() == 2) return (SolidColorBrush)Application.Current.Resources["FlagRedBrush"]; if (value.ParseToInt() == 3) return (SolidColorBrush)Application.Current.Resources["FlagOrangeBrush"]; if (value.ParseToInt() == 4) return (SolidColorBrush)Application.Current.Resources["FlagGreenBrush"]; if (value.ParseToInt() == 5) return (SolidColorBrush)Application.Current.Resources["FlagBlueBrush"]; if (value.ParseToInt() == 5) return (SolidColorBrush)Application.Current.Resources["FlagPurpleBrush"]; return (SolidColorBrush)Application.Current.Resources["FlagGrayBrush"]; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); // 单向绑定可不实现 } } }