/// <summary> /// Adds the current element to the collection of selected items. /// </summary> void ISelectionItemProvider.AddToSelection() { // Return if the item is already selected GlobalCalendarDayButton button = OwningCalendarDayButton; if (button.IsSelected) { return; } GlobalCalendar calendar = OwningCalendar; DateTime? date = button.GetDateNullable(); if (EnsureSelection() && date != null) { if (calendar.SelectionMode == CalendarSelectionMode.SingleDate) { calendar.SelectedDate = date.Value; } else { calendar.SelectedDates.Add(date.Value); } } }
/// <summary> /// Clear any existing selection and then selects the current element. /// </summary> void ISelectionItemProvider.Select() { if (EnsureSelection()) { GlobalCalendar calendar = OwningCalendar; GlobalCalendarDayButton button = OwningCalendarDayButton; calendar.SelectedDates.Clear(); DateTime?date = button.GetDateNullable(); if (date != null) { calendar.SelectedDates.Add(date.Value); } } }
/// <summary> /// Removes the current element from the collection of selected items. /// </summary> void ISelectionItemProvider.RemoveFromSelection() { // Return if the item is not already selected. GlobalCalendarDayButton button = OwningCalendarDayButton; if (!button.IsSelected) { return; } GlobalCalendar calendar = OwningCalendar; DateTime? date = button.GetDateNullable(); if (calendar != null && date != null) { calendar.SelectedDates.Remove(date.Value); } }