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; } } }