WPF datepicker:日期从和日期到 [英] WPF datepicker : Date from and Date To
问题描述
我在WPF画布中有两个日期选择器。我想做的就像是航空公司网站上的日期选择器。第一日历允许用户选择出发日期,第二日历允许用户选择返回日期。假设我从datapickerA中选择11/11/2012,当我单击第二个datepickerB时, 2012/11/11之前的日期被禁用。我应该在日期选择器中放入什么?
I got two datepicker in my WPF canvas. What i trying to do is like the datepicker from airline website. The first calendar allow user to pick the departure date and the second calendar allow user to pick the return date. Let say i select 11/11/2012 from datapickerA, when i click on the second datepickerB, the dates before 11/11/2012 are disabled. What should i put in the datepicker?
推荐答案
您可以使用 DisplayDateStart
DatePicker
的属性。它是 DependencyProperty
,因此您可以使用MVVM通过 DataContext
或通过设置 DatePicker
从第一个的
DatePicker : SelectedDate
> DisplayDateStart
You can use the DisplayDateStart
property of the DatePicker
. It is a DependencyProperty
, so you can supply it via your DataContext
using MVVM, or by setting DisplayDateStart
of your second DatePicker
to SelectedDate
from the first DatePicker
:
<DatePicker x:Name="Date1"/>
<DatePicker DisplayDateStart="{Binding ElementName=Date1, Path=SelectedDate}"/>
这篇关于WPF datepicker:日期从和日期到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!