我有一个DateTime属性.这是绑定到文本框
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding StartDateString, Mode=TwoWay}" x:Name="date" />
Run Code Online (Sandbox Code Playgroud)
在WPF中,可以使用以下语法格式化DateTime输出
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding StartDateString, FormatString="dd.mm.yyyy" Mode=TwoWay}" x:Name="date" />
Run Code Online (Sandbox Code Playgroud)
在Metro应用程序(winrt ... Windows应用商店应用......现在如何调用它?)中,无法使用FormatString属性.
有没有其他方法可以在xaml文件中执行格式化?
小智 10
你是对的.FormatStringWinRT中没有参数.您应该使用值转换器.这是一个应该做你想做的事情的链接:
http://blogs.u2u.be/diederik/post/2012/03/19/A-StringFormat-converter-for-Windows-8-Metro.aspx