【发布时间】:2014-01-14 10:35:06
【问题描述】:
我有两个日期选择器:“dpInputDate”和“dpDueDate”。现在 DueDate 不能小于 InputDate。所以我使用了 BlackoutDates.AddDatesInPast();并且在应用程序启动时工作正常。现在的事情是当我更改 dpInputDate 的选定日期时,dpDueDate 会自动获得相同的值。问题是被涂黑的日期数量保持不变。这是我使用的代码:
private void dpInputDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
dpDueDate.SelectedDate = dpInputDate.SelectedDate;
dpDueDate.BlackoutDates.Clear();
dpDueDate.BlackoutDates.AddDatesInPast();
}
如何管理?
更新:
private void dpDueDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
if (dpDueDate.SelectedDate != null)
{
DateTime date = (DateTime)dpDueDate.SelectedDate;
dpDueDate.BlackoutDates.Clear();
dpDueDate.BlackoutDates.Add(new CalendarDateRange(new DateTime(1 / 1 / 2001), date));
}
else
{
dpDueDate.BlackoutDates.AddDatesInPast();
}
}
【问题讨论】:
标签: c# wpf datepicker