Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Metro (Windows Store App) DateTime Format in XAML

Tags:

winrt-xaml

I haf a DateTime Property. This is Bound to a Textbox with

<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding StartDateString, Mode=TwoWay}" x:Name="date" />

In WPF it was possible to format the DateTime Output with the following syntax

<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding StartDateString, FormatString="dd.mm.yyyy" Mode=TwoWay}" x:Name="date" />

In the Metro Apps (winrt ... Windows Store Apps... how it is called now?), the FormatString property is not possible.

Is there another way to do the format in the xaml file?

like image 513
Sascha Avatar asked Nov 15 '12 18:11

Sascha


1 Answers

You're right. There isn't a FormatString parameter in WinRT. You should probably use a value converter. Here's a link to one that should do what you want:

http://blogs.u2u.be/diederik/post/2012/03/19/A-StringFormat-converter-for-Windows-8-Metro.aspx

like image 123
afreedm1 Avatar answered Sep 21 '22 17:09

afreedm1