XAML 中的 Metro(Windows 应用商店应用)日期时间格式 [英] Metro (Windows Store App) DateTime Format in XAML
问题描述
我有一个 DateTime 属性.这是绑定到带有
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" />
在 WPF 中,可以使用以下语法格式化 DateTime 输出
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" />
在 Metro Apps(winrt ... Windows Store Apps ... 现在如何调用?)中,FormatString 属性是不可能的.
In the Metro Apps (winrt ... Windows Store Apps... how it is called now?), the FormatString property is not possible.
还有其他方法可以在 xaml 文件中进行格式化吗?
Is there another way to do the format in the xaml file?
推荐答案
你说得对.WinRT 中没有 FormatString
参数.您可能应该使用值转换器.这是一个应该做你想做的事情的链接:
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
这篇关于XAML 中的 Metro(Windows 应用商店应用)日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!