简体   繁体   中英

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.

If I select the date as 16 , then all time range can be available to select.

在此处输入图片说明

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 .

But I am afraid there is no "DisplayTimeStart" property that does this for you automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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