Calendar: Selection

This article describes the different selection modes available in TKCalendar

The selection mode in TKCalendar can be altered by using the selectionMode property. The available options are:

  • TKCalendarSelectionModeNode - No selection is allowed.
  • TKCalendarSelectionModeSingle - A single date can be selected.
  • TKCalendarSelectionModeMultiple - Different dates can be selected by tapping on them. A second tap will deselect the date.
  • TKCalendarSelectionModeRange - A range between two dates on the same page can be selected.

Use the selectedDate property to get or set the currently selected date in TKCalendar when the single selection mode is used.

Use the selectedDates property to get or set the selected dates when multiple selection mode is selected.

The selectedDatesRange property is used to store the date range when this selection option is used.

You can determine whether a selection is changed by adopting TKCalendarDelegate protocol:

public override void DidSelectDate (TKCalendar calendar, NSDate date)
    Console.WriteLine (String.Format ("{0}", date));

You can prevent TKCalendar from selecting specific date by handling the calendar:shouldSelectDate:

public override bool ShouldSelectDate (TKCalendar calendar, NSDate date)
    Console.WriteLine (String.Format ("Trying to select the unselectable {0}", date));

    return !TKCalendar.IsDate (main.UnselectableDate, date, NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, main.CalendarView.Calendar);

Furthermore, the calendar:didDeselectDate: is called when using multiple selection to notify for unselected dates:

public override void DidDeselectedDate (TKCalendar calendar, NSDate date)
    Console.WriteLine (String.Format ("{0}", date));
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article