WPF datepicker : Date from and Date To

半世苍凉 提交于 2020-01-23 12:50:48

问题


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?


回答1:


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}"/>


来源:https://stackoverflow.com/questions/13576963/wpf-datepicker-date-from-and-date-to

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!