diff options
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs b/Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs new file mode 100644 index 00000000..357cba3f --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT/BoolToVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System; +using Windows.UI.Xaml; + +#if WINDOWS_UWP + +namespace Xamarin.Forms.Platform.UWP +#else + +namespace Xamarin.Forms.Platform.WinRT +#endif +{ + public sealed class BoolToVisibilityConverter : Windows.UI.Xaml.Data.IValueConverter + { + public bool FalseIsVisible { get; set; } + + public object Convert(object value, Type targetType, object parameter, string language) + { + var v = (bool)value; + if (FalseIsVisible) + v = !v; + + return v ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +}
\ No newline at end of file |