Articles in this section
Category / Section

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

1 min read

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.

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