# Customizing Selection

## Content



You can customize the default behavior of the calendar control to select specific dates. For instance, consider a scenario where you wish to select only weekdays on tapping two dates in different workweeks. For this, you simply need to subscribe the **OnSelectionChanging** event and apply selection condition in the handler.

The following image shows a calendar that only selects weekdays and deselects weekends on tapping two different dates in different workweeks.

![](https://cdn.mescius.io/document-site-files/images/fb6b46a2-eac0-487c-84c3-5e1b4c7b1348/images/calendar_customizeselection.png)

The following code example demonstrates how to customize selection in C# and XAML. This code example uses the sample created in the [Quick start](/componentone/docs/xamarin/online-forms/controls/CalendarOverview/CalendarQuickStart) section.

### In Code

1.  Subscribe the SelectionChanging event in XAML between the \<Grid>\</Grid> tags as depicted below.
    
    ```xml
    <Grid>
        <c1:C1Calendar SelectionChanging="OnSelectionChanging" MaxSelectionCount="-1"/>
      </Grid>
    ```
    
2.  Switch to the code view and add the following code to select only weekdays between two dates in two different weeks.
    
    ```csharp
    private void OnSelectionChanging(object sender, CalendarSelectionChangingEventArgs e)
            {
                foreach (var date in e.SelectedDates.ToArray())
                {
                    if (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)
                        e.SelectedDates.Remove(date);
                }
            }
    ```