Simsons
Simsons

Reputation: 12745

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.

enter image description here

Upvotes: 0

Views: 2691

Answers (1)

mm8
mm8

Reputation: 169200

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.

Upvotes: 1

Related Questions