diff options
-rw-r--r-- | wpspec/wpspec/Converters/ConvertBooleanToVisibility.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/wpspec/wpspec/Converters/ConvertBooleanToVisibility.cs b/wpspec/wpspec/Converters/ConvertBooleanToVisibility.cs new file mode 100644 index 0000000..2628480 --- /dev/null +++ b/wpspec/wpspec/Converters/ConvertBooleanToVisibility.cs @@ -0,0 +1,50 @@ +using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using System.Windows.Data;
+
+namespace wpspec.Converters
+{
+ /// <summary>
+ /// Convert an integer to a 2-digit hex string.
+ /// </summary>
+ public class ConvertBooleanToVisibility : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ object ret = null;
+
+ if (value is bool)
+ {
+ bool b = (bool)value;
+ ret = b ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ return ret;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ object ret = null;
+
+ if (value is Visibility)
+ {
+ Visibility v = (Visibility)value;
+ ret = (v == Visibility.Visible);
+ }
+
+ return ret;
+ }
+
+ #endregion
+ }
+}
|