简体   繁体   English

如何在WPF(MahApps.Metro)日期时间选择器上设置DisplayDateTimeStart

[英]How to set DisplayDateTimeStart on WPF (MahApps.Metro) datetime picker

In my UI I am able to set Minimum date for date picker using following code : 在我的用户界面中,我可以使用以下代码设置日期选择器的“最小日期”:

<Controls:DateTimePicker SelectedDate="{Binding SelectedDate}"
                         DisplayDateStart="{Binding LastUpdatedValue}" 
                         Grid.Row="6" Grid.Column="5" Grid.ColumnSpan="3" Margin="89,1,0,10" Grid.RowSpan="2" />

This takes out all the previous dates for selection which is fine. 这样可以将所有先前的日期都排除掉,这很好。 Is there way to restrict time as well. 还有限制时间的方法。

For example, If I have selected 15 June 2018, 3:34:06 PM as my start date , the time picker should restrict any time that's before it. 例如,如果我选择了2018年6月15日下午3:34:06作为开始日期,则时间选择器应限制在此之前的任何时间。

If I select the date as 16 , then all time range can be available to select. 如果我将日期选择为16,则可以选择所有时间范围。

在此处输入图片说明

Is there way to restrict time as well. 还有限制时间的方法。

You can set the SourceHours , SourceMinutes and SourceSeconds properties of the DateTimePicker control to a range of integers ( IEnumerable<int> ) that you want to be displayed in the ComboBoxes . 您可以将DateTimePicker控件的SourceHoursSourceMinutesSourceSeconds属性设置为要在ComboBoxes显示的整数范围( IEnumerable<int> )。

But I am afraid there is no "DisplayTimeStart" property that does this for you automatically. 但是,恐怕没有“ DisplayTimeStart”属性可以自动为您执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM