BooleanTransformer Element

Converts data to a Boolean value.

Syntax

<BooleanTransformer
    Inverse="{true | false}"
/>

Attributes

Inverse

Returns the inverse result of the conversion.

Remarks

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

<Mcml 
  xmlns="http://schemas.microsoft.com/2006/mcml"
  xmlns:cor="assembly://MSCorLib/System">

  <UI Name="BooleanTransformer">

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

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

    <Content>
      <Panel Layout="VerticalFlow">
        <Children>
          
          <!-- 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"/>
          
        </Children>
      </Panel>
    </Content>

  </UI>
</Mcml>

Requirements

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

See Also

Show: