WinUI | ComponentOne
Controls / Calendar / Selection
In This Topic
    Selection
    In This Topic

    By default, Calendar allows you to select a day in the displayed calendar month. However, you can change this default behavior by using SelectionMode property of the C1Calendar class that manages the date selection in the control. The SelectionMode property allows you to select a single date or multiple dates using the SelectionMode enumeration which specifies the selection behavior of the Calendar control. In addition, Calendar also allows you to limit the maximum number of days that can be selected by a user using the MaxSelectionCount property.

    The following image shows a date range selected in the calendar control.

    WinUI Calendar showing date range selection

    To allow the user to select a date range with limited number of days, use the following code. In this example, we are setting the SelectionMode property to SelectionMode.Multiple to allow user to select multiple dates and setting the MaxSelectionCount to 8 to set it as a limit for date range selection.

    C#
    Copy Code
    <calendar:C1Calendar x:Name="calendar" SelectionMode="Multiple" MaxSelectionCount="8" HorizontalAlignment="Center" VerticalAlignment="Top"></calendar:C1Calendar>