TimeSpanTransformer Element

Converts a TimeSpan value to a string for display purposes.

Syntax

<TimeSpanTransformer
    Format="{Abbreviate | Long | RoundToMinute | Short | Words}"
/>

Attributes

Format

Specifies the time span format. This value must be a member of the TimeSpanFormats enumeration.

Remarks

For more information about TimeSpan format, see the TimeSpan Structure on the MSDN web site.

The target of the TimeSpanTransformer element must accept a string.

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="https://schemas.microsoft.com/2006/mcml"
  xmlns:cor="assembly://MSCorLib/System"
  xmlns:me="Me">

  <!-- TimeSpan values are being bound to the value properties of several -->
  <!-- Text items as strings.                                             -->

  <UI Name="TimeSpanTransformer">

    <Locals>
      <cor:TimeSpan Name="TimeSpanValue" cor:TimeSpan="3:46:35"/>
    </Locals>

    <Rules>
      <Binding Source="[TimeSpanValue]" Target="[Long.Content]">
        <Transformer>
          <TimeSpanTransformer Format="Long"/>
        </Transformer>
      </Binding>

      <Binding Source="[TimeSpanValue]" Target="[Long_RoundToMinute.Content]">
        <Transformer>
          <TimeSpanTransformer Format="Long,RoundToMinute"/>
        </Transformer>
      </Binding>

      <Binding Source="[TimeSpanValue]" Target="[Short.Content]">
        <Transformer>
          <TimeSpanTransformer Format="Short"/>
        </Transformer>
      </Binding>

      <Binding Source="[TimeSpanValue]" Target="[Words.Content]">
        <Transformer>
          <TimeSpanTransformer Format="Words"/>
        </Transformer>
      </Binding>

      <Binding Source="[TimeSpanValue]" Target="[Words_Abbreviate.Content]">
        <Transformer>
          <TimeSpanTransformer Format="Words,Abbreviate"/>
        </Transformer>
      </Binding>

    </Rules>

    <Content>
      <Panel Layout="VerticalFlow">
        <Children>
          <me:ValueText Name="Long" />
          <me:ValueText Name="Long_RoundToMinute" />
          <me:ValueText Name="Short" />
          <me:ValueText Name="Words" />
          <me:ValueText Name="Words_Abbreviate" />
        </Children>
      </Panel>
    </Content>
  </UI>

  <UI Name="ValueText">
    <Properties>
      <cor:String Name="Content" String=""/>
    </Properties>

    <Content>
      <Text Content="[Content]" Font="Verdana,16" Color="Yellow" Margins="10,5,10,5" />
    </Content>

  </UI>
</Mcml>

Requirements

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

See Also