diff options
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/ColorConverter.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT/ColorConverter.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/ColorConverter.cs b/Xamarin.Forms.Platform.WinRT/ColorConverter.cs new file mode 100644 index 00000000..3866e435 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/ColorConverter.cs @@ -0,0 +1,30 @@ +using System; +using Windows.UI; +using Windows.UI.Xaml.Media; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + public sealed class ColorConverter : Windows.UI.Xaml.Data.IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + var color = (Color)value; + var defaultColorKey = (string)parameter; + + Brush defaultBrush = defaultColorKey != null ? (Brush)Windows.UI.Xaml.Application.Current.Resources[defaultColorKey] : new SolidColorBrush(Colors.Transparent); + + return color == Color.Default ? defaultBrush : color.ToBrush(); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +}
\ No newline at end of file |