TimeSpanTransformer Element

Converts a TimeSpan value to a string for display purposes.


    Format="{Abbreviate | Long | RoundToMinute | Short | Words}"



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


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


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

  <UI Name="TimeSpanTransformer">

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

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

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

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

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

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


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

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

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



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

See Also