Completed feedback form
[pithos-ms-client] / trunk / Pithos.Client.WPF / Converters / EmptyToVisibilityConverter.cs
diff --git a/trunk/Pithos.Client.WPF/Converters/EmptyToVisibilityConverter.cs b/trunk/Pithos.Client.WPF/Converters/EmptyToVisibilityConverter.cs
new file mode 100644 (file)
index 0000000..ce13b00
--- /dev/null
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Data;
+
+namespace Pithos.Client.WPF.Converters
+{
+    /// <summary>
+    /// Returns Visible if a string value contains data, Hidden otherwise
+    /// </summary>
+    public class EmptyToVisibilityConverter:IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            var stringValue = value as string;
+
+            if (String.IsNullOrWhiteSpace(stringValue))
+                return Visibility.Hidden;
+            return Visibility.Visible;
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}