Articles in this section

How to handle the long press action on date selection in WinUI Scheduler (Calendar)

Using the CellLongPressed event in the WinUI SfScheduler, handle the long-press action on date selection.

XAML

The SfScheduler handles the CellLongPressed event handler.

<Grid>
    <scheduler:SfScheduler 
    x:Name="Schedule"
    ViewType="Month"
    CellLongPressed="OnCellLongPressed">
    </scheduler:SfScheduler>
</Grid>

C#

In the CellLongPressed event, get the long pressed date details by using the property of DateTime of CellLongPressedEventArgs.

//Event Customization
private async void OnCellLongPressed(object sender, CellLongPressedEventArgs e)
{
    var dateTime = e.DateTime.ToString();
    ContentDialog contentDialog = new ContentDialog()
    {
        Title = "DateCellHold Response",
        Content = "DateCell" + " " + e.DateTime.Day + " " + "has been long pressed",
        CloseButtonText = "Ok"
    };
 
    //Set XamlRoot for WinUI desktop applications
    contentDialog.XamlRoot = this.Schedule.XamlRoot;
    await contentDialog.ShowAsync();
}

Diagram

Description automatically generated with low confidence

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied