NoesisGUI

BooleanToVisibilityConverter Class

Use the BooleanToVisibilityConverter class to convert a Boolean to and from a Visibility value. The Convert method returns Visibility.Visible when true is passed in or Visibility.Collapsed when false is passed in. Note that the Visibility.Collapsed value hides the control and does not reserve space for it in a layout. When you call the ConvertBack method and specify a reference to an object, it returns true if the object is Visible; otherwise, it returns false.

<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Background="Gray">

    <Grid.Resources>
        <BooleanToVisibilityConverter x:Key="converter"/>
    </Grid.Resources>

    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
        <CheckBox x:Name="checkBox" Content="Show Button" Width="100"/>
        <Button Content="Click" Margin="5" Visibility="{Binding ElementName=checkBox,
            Path=IsChecked, Converter={StaticResource converter}}"/>
    </StackPanel>

</Grid>

https://msdn.microsoft.com/en-us/library/system.windows.controls.booleantovisibilityconverter

Inheritance Hierarchy

BooleanToVisibilityConverter

INDEX Class Hierarchy Index

Methods

From BaseValueConverter

Name Description
TryConvert The data binding engine calls this method when it propagates a value from the binding source to the binding target
TryConvertBack The data binding engine calls this method when it propagates a value from the binding target to the binding source

Properties

BooleanToVisibilityConverter has no properties

Events

BooleanToVisibilityConverter has no events

© 2017 Noesis Technologies