Exemple #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType.IsAssignableFrom(typeof(ISolidColorBrush)))
            {
                if (value is Color c)
                {
                    return(new SolidColorBrush(c));
                }

                if (value is Color2 c2)
                {
                    return(new SolidColorBrush(c2));
                }

                if (value is string c3 && Color.TryParse(c3, out var cc))
                {
                    return(new SolidColorBrush(cc));
                }
            }
            else
            {
                if (value is string c3 && Color2.TryParse(c3, out var cc))
                {
                    return(cc);
                }
            }
            return(value);
        }