We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to drag appointment to the exact hour in Schedule (SfSchedule) Xamarin.Forms

Platform: Xamarin.Forms |
Control: SfSchedule |
Published Date: March 2, 2020 |
Last Revised Date: March 3, 2020

You can drag the appointment to the exact hour in Xamarin.Forms SfSchedule using the AllowAppointmentDrag property and AppointmentDrop event.

Enable appointment drag and drop-in schedule by setting the AllowAppointmentDrag property of SfSchedule to True.

<schedule:SfSchedule x:Name="schedule" AllowAppointmentDrag="True"/>

Initialize an event handler for AppointmentDrop event of Schedule.

schedule.AppointmentDrop += ScheduleOnAppointmentDrop;

In AppointmentDrop event handler, get the drop time of appointment using the DropTime property of event, round off the value to exact hour by mentioning the minute value to zero and assign the rounded off value to the DropTime property of event.

private void ScheduleOnAppointmentDrop(object sender, AppointmentDropEventArgs e)
{
      var dropTime = e.DropTime;
      e.DropTime = new DateTime(dropTime.Year, dropTime.Month, dropTime.Day, dropTime.Hour, 0, 0);
}

Output:

Appointment drag and drop

Download the sample from GitHub.

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile