有没有办法删除日历控件中涂黑的日期以便再次选择它们?

Is There a Way To Remove Blacked Out Dates In The Calendar Control So They Can Be Selected Again?

我正在尝试使用日历控件来选择医生预约的日期,当医生不在时,日期会被涂黑,因此您无法 select 他们。涂黑效果很好,但是当它改变 selected doctor 时,涂黑的日期会叠加,因此它限制了在另一位医生之后 selected 的医生的可用天数。

我正在尝试在 WPF 应用程序中执行此操作

这是我用来取消日期的代码:

DocAvail da = new DocAvail();
DataTable dt;
// GetAvailability() just runs an SQL statement selected the days that the doctor isn't 
// available and returns it in a DataTable
dt = da.GetAvailability(docID);

foreach (DataRow dr in dt.Rows) {
    for (DateTime day = min; day <= max; day = day.AddDays(1)) {
        if (day.DayOfWeek.ToString() == dr["nameofDay"].ToString()) {
                        calAppointment.BlackoutDates.Add(new CalendarDateRange(day));
        }
    }
}

我真傻,这行得通: calAppointment.BlackoutDates.Clear();

添加新的之前只需调用 Clear

calAppointment.BlackoutDates.Clear();