.netwpfbindingvisibility

How do I invert 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.


Solution

  • 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.