TextBlock中的WPF格式DateTime? [英] WPF format DateTime in TextBlock?
本文介绍了TextBlock中的WPF格式DateTime?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个绑定到 DateTime
属性的 TextBlock
。如何配置日期的格式?
I have a TextBlock
that is bound to a DateTime
property. How do I configure the format of the date?
推荐答案
当声明绑定时,有一个字符串格式属性可用: / p>
There is a string format property available when you are declaring the binding:
<Textbox Text="{Binding Path=DateTimeValue, StringFormat=dd-MM-yyyy}" />
(您需要在.NET 3.5 SP1上才能存在此属性)
(You need to be on .NET 3.5 SP1 for this property to exist)
这篇关于TextBlock中的WPF格式DateTime?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文