O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Customizing the Value Format

The format of the DateTime value can be specified by setting the DatePicker or TimePicker ValueStringFormat property. For example, to present the DateTime value of a TimePicker using a long time format, the ValueStringFormat is set to {0:T}. Because curly brackets are treated as special characters in XAML, they must be escaped. This is done by prefixing {} to the format string, as shown in the following excerpt:

<toolkit:TimePicker x:Name="timePicker"                    Value="{Binding Time, Mode=TwoWay}"                    Header="time with custom format"                    ValueStringFormat="{}{0:T}"/>

Alternatively, to set the format in the code-beside, you could use the following: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required