diff options
Diffstat (limited to 'Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs')
| -rw-r--r-- | Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs b/Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs new file mode 100644 index 0000000..ff9f6a3 --- /dev/null +++ b/Codemerx/Gestor.Common/Gestor.Common.Converters/IdToVisibilityConverter.cs @@ -0,0 +1,30 @@ +using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+using System.Windows.Markup;
+
+namespace Gestor.Common.Converters
+{
+ public class IdToVisibilityConverter : MarkupExtension, IValueConverter
+ {
+ public IdToVisibilityConverter()
+ {
+ }
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (value == null || (int)Math.Round(double.Parse(value.ToString())) == 0 ? Visibility.Visible : Visibility.Collapsed);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (value == null || string.IsNullOrEmpty(value.ToString()) ? 0 : int.Parse(value.ToString()));
+ }
+
+ public override object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return this;
+ }
+ }
+}
\ No newline at end of file |