如何反转 BooleanToVisibilityConverter? [英] How do I invert BooleanToVisibilityConverter?

查看:33
本文介绍了如何反转 BooleanToVisibilityConverter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 WPF 中使用 BooleanToVisibilityConverter 将控件的 Visibility 属性绑定到 Boolean.这工作正常,但我希望其中一个控件隐藏布尔值是否为 true,并显示它是否为 false.

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

在您的 Convert 方法中,让它返回您想要的值而不是默认值.

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

这篇关于如何反转 BooleanToVisibilityConverter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆