Nexmo

VisibilityConverter : IValueConverter

Nov 7th, 2021
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. class BoolToVisibilityConverter : IValueConverter
  2.     {
  3.         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  4.         {
  5.             if ((bool)value)
  6.                 return Visibility.Visible;
  7.             else
  8.                 return Visibility.Hidden;
  9.         }
  10.  
  11.         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  12.         {
  13.             if ((Visibility)value == Visibility.Hidden)
  14.                 return true;
  15.             else
  16.             {
  17.                 return false;
  18.             }
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment