How to handle the long press action on date selection in WPF Scheduler (Calendar)
You can handle the long press action on date selection by using the CellLongPressed event in WPF SfScheduler.
XAML
Interaction behavior added to SfScheduler to handle the CellLongPressed event handler.
<Grid> <syncfusion:SfScheduler x:Name="Schedule" ViewType="Month" > <interactivity:Interaction.Behaviors> <local:SchedulerBehavior/> </interactivity:Interaction.Behaviors> </syncfusion:SfScheduler> </Grid>
C#
In CellLongPressed event, you can get the long pressed date details by using the property of DateTime of CellLongPressedEventArgs.
public class SchedulerBehavior : Behavior<SfScheduler>
{
SfScheduler scheduler;
protected override void OnAttached()
{
base.OnAttached();
scheduler = this.AssociatedObject;
this.AssociatedObject.CellLongPressed += AssociatedObject_CellLongPressed;
}
private void AssociatedObject_CellLongPressed(object sender, CellLongPressedEventArgs e)
{
MessageBox.Show("DateCell" + " " + e.DateTime.Day + " " + "has been long pressed", "DateCellHold Response", MessageBoxButton.OK);
}
protected override void OnDetaching()
{
base.OnDetaching();
this.AssociatedObject.CellLongPressed -= AssociatedObject_CellLongPressed;
this.scheduler = null;
}
}
