#1,034 – Limiting the Range of Selectable Dates in a Calendar
March 21, 2014 2 Comments
The Calendar control allows selecting one or more dates. By default, the user is allowed to select dates within the range DateTime.MinValue (1/1/0001) to DateTime.MaxValue (12/31/9999).
If you want to restrict the user to dates within a more reasonable range, you can set the DisplayDateStart and DisplayDateEnd properties. The Calendar will then be limited to dates within that range.
<Label Content="Pick your favorite day from the 1980s:"/> <Calendar DisplayDateStart="1/1/1980" DisplayDateEnd="12/31/1989"/>
These properties also work in the DatePicker control, to limit the dates that can be selected.
Pingback: Dew Drop – March 21, 2014 (#1748) | Morning Dew
Pingback: #1,038 – Another Way to Prevent Certain Dates from Being Selected | 2,000 Things You Should Know About WPF