1

Currently i developing a WPF application. My application allow user to select any date from the datepicker and data from the selected date will show up. However, user is not allow to select any specific time from the datepicker. The output from the datepicker will be something like 02-dec-2012 12:00:00 AM. The time from the datepicker will always be 12:00am. So, how can i allow user to alter the time? I found some resource from DateTimePicker, but i looking for another solution. Any advice? Thanks

4

1 回答 1

1

WPF DatePicker 不支持时间选择或显示。它只支持日期选择。

一个简单的解决方法是使用多个 TextBox 控件并将它们的 Text 属性绑定到 DateTime 数据源,以允许用户查看和更改时间。

有关 DataBinding 的更多信息,请参阅http://msdn.microsoft.com/en-us/library/ms752347.aspx

如果要在 DatePicker 中添加时间选择功能,则需要引入自定义控件。

有关自定义控件的更多信息,请参阅http://msdn.microsoft.com/en-us/library/ms745025.aspx

资源

您还可以查看以下示例以了解如何执行此操作:示例项目

于 2012-12-10T09:23:06.527 回答