using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Data; namespace PipeGallery.Converter { public class VisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { int p = System.Convert.ToInt32(parameter); if (p == 0) { if ((bool)value) { return Visibility.Collapsed; } else { return Visibility.Visible; } } else if (p == 1) { if (value.ToString() == "0") { return Visibility.Collapsed; } else { return Visibility.Visible; } } else if (p == 2) { if (value.ToString() == "1") { return Visibility.Collapsed; } else { return Visibility.Visible; } } else { } return null; } catch { return null; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } }