dbnetsoft
ScreensPro
ScreensPro
  • Projects & Configs
    • Visual Studio Projects
  • Layouts
    • Converters
      • Visibility Converter
  • Sources
    • Example
  • Custom Controls
    • VideoElement
    • VideoElement2
    • StopwatchElement
    • Stopwatch2Element
    • ImageElement
Powered by GitBook
On this page
  1. Layouts
  2. Converters

Visibility Converter

The ObjectToVisibilityConverter is available as it's own name as static resource. It will check upon the bound data and either returns Visibility.Visible (show) or Visibility.Collapsed (hide).

If you set false as parameter, then the outcome is reversed.

Example

If you have a Nation's property local data context, and you want the parent border to be only visible when the nation is set (set means either null or empty string) then you can use the converter:

 <Border Visibility="{Binding Local.Nation, Converter={StaticResource ObjectToVisibilityConverter}}" Background="{DynamicResource BackgroundBrush}" Height="{DynamicResource ElementHeight}" HorizontalAlignment="{Binding Local.HorizontalAlignment}" >
      <userControls:ImageElement x:Name="NationTextBlock" Filename="{Binding Local.Nation}" Path="Images\Flags" Extension="{DynamicResource FlagExtension}" Margin="{DynamicResource FlagMargin}"  HorizontalAlignment="Left" VerticalAlignment="Center" />
 </Border>
PreviousConvertersNextSources

Last updated 2 months ago