diff options
Diffstat (limited to 'Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs')
| -rw-r--r-- | Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs b/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs new file mode 100644 index 0000000..4baccf6 --- /dev/null +++ b/Gestor.Common/Gestor.Common.Converters/BoolToEyeConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; + +namespace Gestor.Common.Converters; + +public class BoolToEyeConverter : MarkupExtension, IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return "Eye"; + } + if (!(bool)value) + { + return "Eye"; + } + return "EyeOff"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (value != null && !string.IsNullOrEmpty(value.ToString())) ? int.Parse(value.ToString()) : 0; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + return this; + } +} |