using System; using Windows.UI.Xaml.Data; namespace OwlCore.WinUI.Converters.Color { /// /// A converter that converts a given nullable to a with a backup color. /// public class NullableBackupColorConverter : IValueConverter { /// /// Gets or sets the backup color for the converter instance. /// public Windows.UI.Color BackupColor { get; set; } /// /// Converts a nullable to a with a backup color. /// /// The to convert. /// The backup color if is null. /// The converted value. public static Windows.UI.Color Convert(Windows.UI.Color? value, Windows.UI.Color backup) => value ?? backup; /// public object Convert(object value, Type targetType, object parameter, string language) { Windows.UI.Color? color = value as Windows.UI.Color?; return Convert(color, BackupColor); } /// public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } }