1

我对可见性有这个绑定

Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"

我想设置Visibility = FalseifComputedVerticalScrollBarVisibility = TrueVisibility = TrueifComputedVerticalScrollBarVisibility = false

有没有这样的东西:

Visibility="!{TemplateBinding ComputedVerticalScrollBarVisibility}"

谢谢赛

4

1 回答 1

2

To Hasan's point, the converter here is pretty simple:

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();
    }
}
于 2012-05-24T15:20:07.920 回答