public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values != null && values.Length > 1 && (values[0] is StatusType) && (values[1] is IStatusTheme)) { StatusType StatusType = (StatusType)values[0]; IStatusTheme Theme = (IStatusTheme)values[1]; if (Theme != null) { return(Theme.GetBackgroundBrush(StatusType)); } } return(null); }
/// <summary> /// Converts from status types to a theme background brush. /// </summary> /// <param name="values">The array of values to convert.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns>The converted value.</returns> public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values != null && values.Length >= 2) { if (values[0] == DependencyProperty.UnsetValue) { return(null !); } if ((values[0] is StatusType) && (values[1] is IStatusTheme)) { StatusType StatusType = values[0] is StatusType ? (StatusType)values[0] : StatusType.Normal; IStatusTheme Theme = (IStatusTheme)values[1]; return(Theme.GetBackgroundBrush(StatusType)); } } throw new ArgumentOutOfRangeException(nameof(values)); }