C# WPF 4.0 的 DateTimePicker
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10658472/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DateTimePicker for WPF 4.0
提问by Arsen Zahray
According to this post, there's a separate DatePicker control in .net 4. I've tried it, and I don't see a good way to also let it select the time of the day.
根据这篇文章,.net 4 中有一个单独的 DatePicker 控件。我已经尝试过了,但我没有看到让它选择一天中的时间的好方法。
Is there an easy way to transform DatePicker into DateTimePicker by editing XAML template? If not, what is the best way to get a DateTimePicker for WPF 4.0?
有没有一种简单的方法可以通过编辑 XAML 模板将 DatePicker 转换为 DateTimePicker?如果没有,为 WPF 4.0 获取 DateTimePicker 的最佳方法是什么?
采纳答案by Dean Kuga
Extended WPF Toolkitsports a nice DateTimePickerwith time of day.
扩展的 WPF 工具包带有一个很好的DateTimePicker和一天中的时间。
There is also an article over on CP where someone created a control that works like the Winforms one... A WPF DateTimePicker That Works Like the One in Winforms
还有一篇关于 CP 的文章,其中有人创建了一个像 Winforms 一样工作的控件......一个像 Winforms 中那样工作的 WPF DateTimePicker
回答by Kevin DiTraglia
There isn't one without making it yourself or using a 3rd party control. However there is one within winforms if you want a quick fix that doesn't support data binding...
没有自己制作或使用第 3 方控件的情况下是没有的。但是,如果您想要一个不支持数据绑定的快速修复,那么在 winforms 中有一个...
xmlns:window="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
<window:WindowsFormsHost >
<wf:DateTimePicker Format="Time" ></wf:DateTimePicker>
</window:WindowsFormsHost>
Just a time picker, but could easily be paired with a datepicker. You also need a reference to WindowsFormsIntegration and System.Windows.Forms.
只是一个时间选择器,但可以很容易地与日期选择器配对。您还需要引用 WindowsFormsIntegration 和 System.Windows.Forms。
回答by Phil
Try the DateTimePickerin the extended WPF toolkit.
尝试扩展 WPF 工具包中的DateTimePicker。

