Skip to content
This repository was archived by the owner on Aug 27, 2020. It is now read-only.

NullOrEmptyBooleanConverter

Mark Smith edited this page Aug 29, 2016 · 1 revision

NullOrEmptyBooleanConverter

This value converter takes an input object or string and returns a boolean value based on whether the input is null/empty.

This can be used inline with a binding, or if you want to reuse the object, you can place it into a resource dictionary.

Properties

  • Empty : the boolean value to return if the input is null/empty. Defaults to `false'.
  • NotEmpty : the boolean value to return if the input has a value. Defaults to `true'.

Example

<Entry x:Name="nameEntry" Text="{Binding Name, Mode=TwoWay}" />
<Label TextColor="Red" Text="You must supply a name"
       IsVisible="{Binding Name, 
               Converter={cvt:NullOrEmptyBooleanConverter Empty=true, NotEmpty=false}}" />