diff options
Diffstat (limited to 'Xamarin.Forms.Platform.WP8/Converters/ColorConverter.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WP8/Converters/ColorConverter.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WP8/Converters/ColorConverter.cs b/Xamarin.Forms.Platform.WP8/Converters/ColorConverter.cs new file mode 100644 index 00000000..1e495ecf --- /dev/null +++ b/Xamarin.Forms.Platform.WP8/Converters/ColorConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Globalization; +using System.Windows.Media; + +namespace Xamarin.Forms.Platform.WinPhone +{ + public class ColorConverter : System.Windows.Data.IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var color = (Color)value; + var defaultColorKey = (string)parameter; + + Brush defaultBrush = defaultColorKey != null ? (Brush)System.Windows.Application.Current.Resources[defaultColorKey] : new SolidColorBrush(Colors.Transparent); + + return color == Color.Default ? defaultBrush : color.ToBrush(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + } +}
\ No newline at end of file |