我如何翻转BooleanToVisibilityConverter?BooleanToVisibilityConverter

2023-09-02 01:29:04 作者:时光凉春衫薄

我在WPF中使用 BooleanToVisibilityConverter 绑定可见性控制的属性设置为布尔。这工作得很好,但我想其中一个控件隐藏如果布尔是,并显示它是否

I'm using a BooleanToVisibilityConverter in WPF to bind the Visibility property of a control to a Boolean. This works fine, but I'd like one of the controls to hide if the boolean is true, and show if it's false.

推荐答案

实现你自己的实现的IValueConverter的。示例实现是

Implement your own implementation of IValueConverter. A sample implementation is at

的http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx

在您的转换方法,使其返回的值,你想,而不是缺省值。

In your Convert method, have it return the values you'd like instead of the defaults.

相关推荐