BooleanTransformer Element

Converts data to a Boolean value.


    Inverse="{true | false}"



Returns the inverse result of the conversion.


The following types are supported:

  • Int32: true if non-zero; false if zero.
  • Single: true if non-zero; false if zero.
  • Double: true if non-zero; false if zero.
  • String: true if non-zero; false if zero.
  • Boolean: Returns the current value.
  • ICollection: true for a non-zero count; false for a zero count.

The target of a BooleanTransformer must accept a Boolean value.

You cannot perform one conversion after another on the same variable in a chain. To perform multiple conversions, you can transform the value to an intermediate local and then bind that value to your target using another transformer, or use multiple actions on the same variable using a rule.

Example Code


  <UI Name="BooleanTransformer">

    <!-- Two values: one is non-zero, one is zero. -->
      <cor:Int32  Name="ValueT" Int32="1" />
      <cor:Single Name="ValueF" Single="0" /> 

    <!-- These rules bind the Boolean values to the Visible properties of the Text elements. -->
      <Binding Source="[ValueT]" Target="[LabelT.Visible]">
          <BooleanTransformer />
      <Binding Source="[ValueF]" Target="[LabelF.Visible]">
          <BooleanTransformer />

      <Panel Layout="VerticalFlow">
          <!-- These are invisible by default (Visible="false"). -->
          <Text Name="LabelT" Content="This is visible because the value is non-zero" 
                Color="BlanchedAlmond" Font="Verdana,30" Visible="false"/>

          <Text Name="LabelF" Content="This is not visible because the value is zero" 
                Color="BlanchedAlmond" Font="Verdana,30" Visible="false"/>



Platform: Windows Vista Ultimate, Windows Vista Home Premium, and later

See Also