WPF按钮可见性问题

时间:2012-05-24 14:40:27

标签: wpf button visibility

我对Visibility有这种约束

Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"

我想设Visibility = False ComputedVerticalScrollBarVisibility = TrueVisibility = True if ComputedVerticalScrollBarVisibility = false

有这样的事情:

Visibility="!{TemplateBinding ComputedVerticalScrollBarVisibility}"

由于 西

1 个答案:

答案 0 :(得分:2)

至于Hasan的观点,转换器非常简单:

public class VisibilityInverterConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value != null && value is Visibility)
        {
            var vis = (Visibility) value;

            if (vis == Visibility.Hidden || vis == Visibility.Collapsed)
            {
                return Visibility.Visible;
            }

            return Visibility.Collapsed;
        }

        return Visibility.Visible;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}