Export (0) Print
Expand All
Expand Minimize

DateTimeTransformer Element

Converts date-time data to a string for display purposes.

Syntax

<DateTimeTransformer
    Format="DateTimeFormats enumeration"
/>

Attributes

Format

Specifies a date-time format. This value must be a member of the DateTimeFormats enumeration.

Remarks

The target of the DateTimeTransformer 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="http://schemas.microsoft.com/2006/mcml"
  xmlns:cor="assembly://MSCorLib/System"
  xmlns:me="Me">

  <UI Name="DateTimeTransformer">

    <Locals>
      <cor:DateTime Name="DateTimeValue" cor:DateTime="2006-01-26 15:32:54"/>
    </Locals>

    <Rules>
      <!-- This rule converts the date-time value to a short date + short time string. -->
      <Binding Source="[DateTimeValue]" Target="[Example1.DateTimeString]">
        <Transformer>
          <DateTimeTransformer Format="ShortDate,ShortTime"/>
        </Transformer>
      </Binding>
      <!-- This rule converts the date-time value to a long date with an abbreviated day string. -->
      <Binding Source="[DateTimeValue]" Target="[Example2.DateTimeString]">
        <Transformer>
          <DateTimeTransformer Format="LongDate,AbbreviateNames"/>
        </Transformer>
      </Binding>
    </Rules>

    <Content>
      <Panel Layout="VerticalFlow">
        <Children>
          <Panel Layout="HorizontalFlow">
            <Children>
              <me:LabelText LabelString="This example shows a short date + time: "/>
              <me:ValueText Name="Example1"/>
            </Children>
          </Panel>
          <Panel Layout="HorizontalFlow">
            <Children>
              <me:LabelText LabelString="This example shows a long date + abbreviated name: "/>
              <me:ValueText Name="Example2"/>
            </Children>
          </Panel>

        </Children>
      </Panel>
    </Content>

  </UI>

  <UI Name="LabelText">

    <Properties>
      <cor:String Name="LabelString" String=""/>
    </Properties>

    <Content>
      <Text Content="[LabelString]" Font="Verdana,16" Color="LightCoral"
        Margins="10,5,10,5" MinimumSize="400,0" MaximumSize="600,0" WordWrap="true"/>
    </Content>

  </UI>

  <UI Name="ValueText">

    <Properties>
      <cor:String Name="DateTimeString" String=""/>
    </Properties>

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

  </UI>
</Mcml>

Requirements

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

See Also

Show:
© 2015 Microsoft