WPF Personal FAQs

di Luigi Boschetti

BoolToVisibilityConverter

BoolToVisibility converter is a standard converter that allows to convert a boolean value to a Visibility value for WPF controls. To use it:

In a UserControl/Window xaml file:

  1. In the Resources, declare the Converter:
<UserControl.Resources>
    <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
</UserControl.Resources>

2. Use the converter in Binding instruction:

<UserControl Visibility="{Binding boolValue, Converter={StaticResource BoolToVisibilityConverter}}"/>