Snapping Appointments
RadScheduleView provides the option to automatically snap the appointments while resizing/dragging them. This behavior is enabled through the SnapAppointments Boolean property:
This way during drag/resize operation the Start/End times of the appointment will be rounded according to the TimeSlots’ length:
When dragging an appointment, the default snap behavior rounds the appointment's start time to the closest tick.
You could set MinorTickLength property of the ViewDefinition in order to snap the appointments to different duration:
And the result is:
You can check Configuring the TimeRuler ticks article for more details about MinorTickLength property.
Customizing the SnapBehavior
For more advanced scenarios when snapping of the appointments is not directly connected with the time slots, the RadScheduleView control provides a way to customize the snapping of the appointments in a more detailed manner. You just need to create a class which inherits from Telerik.Windows.Controls.ScheduleView.SnapBehavior and to override its SnapStart and SnapEnd methods. Then an instance of this class should be set to the SnapBehavior property of RaddScheduleView.
In the next example it is demonstrated how to set the snapping to 5 minutes regardless of the TimeSlots length.
- First, create CustomSnapBehavior class:
- Override the needed methods:
- Attach the newly created custom behavior to the ScheduleView control:
So now the appointments are snapped to 5 minutes: