结合日期时间日期在控制 [英] Binding Date of DateTime in a control
本文介绍了结合日期时间日期在控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Text="{Binding Path=PostDate.Date}"
我不希望显示在我的控制部分时间。
而不是2010年8月26日上午12:00,我想2010年8月26日。
I don't want to show the time part in my control. Instead of 8/26/2010 12:00 AM, I want 8/26/2010.
有没有简单的方法来做到这一点没有任何明确/隐式转换或重写一些方法?
Is there any easy way to do that without any explicit/implicit conversion or overriding some methods ?
推荐答案
由于3.5 SP1,则可以使用Binding.StringFormat。请参见这个帖子获取更多的例子。
Since 3.5 SP1, you can use Binding.StringFormat. See this post for more examples
Text="{Binding Path=PostData.Data, StringFormat={}{0:MM/dd/yyyy}}"
这篇关于结合日期时间日期在控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文