SchedulerControl.AppointmentResize Event
Occurs when an appointment’s interval is modified by dragging its borders.
Namespace: DevExpress.Xpf.Scheduling
Assembly: DevExpress.Xpf.Scheduling.v18.2.dll
Declaration
Event Data
The AppointmentResize event's data class is AppointmentItemResizeEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Allow | Gets or sets whether the appointment can be resized. |
HitInterval | Retrieves the datetime range to which the appointment’s side is moved. |
HitResource | Gets the resource assigned to cells to which an appointment’s side is moved. |
ResizedSide | Indicates which appointment side is being moved when the appointment is resized. |
State | Indicates the stage of the resize action. |
ViewModel | Provides access to the View Model for the resized appointment. |
Remarks
The event argument provides an information on a stage of resizing action, the resource and time interval associated with time cells to which the appointment’s edge is moved, and also indicates which side of the appointment is moved. The AppointmentItemResizeEventArgs.ViewModel property provides access to the modified appointment.
The original appointment (before resizing) is accessible using the AppointmentEditViewModelBase.Appointment property of the AppointmentDragResizeViewModel object contained in the AppointmentItemDragDropEventArgs.ViewModels collection.
To cancel resizing, set the AppointmentItemResizeEventArgs.Allow property to false.
Example
This code handles the SchedulerControl.AppointmentResize
event to determine whether a resize operation is allowed based on the custom field value. If a custom field “FixedTime” exists and is set to false, resizing downwards (i.e., the AppointmentItemResizeEventArgs.ResizedSide is ResizedSide.AtStartTime) is not allowed. A “FixedTime” field value set to true cancels any resizing.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-handle-appointment-drag-drop-resize-operations-t605963.
public void OnAppointmentResize(DevExpress.Xpf.Scheduling.AppointmentItemResizeEventArgs e)
{
if (e.ViewModel.CustomFields["FixedTime"] != null)
if ((bool)e.ViewModel.CustomFields["FixedTime"] ||
e.ResizedSide == DevExpress.XtraScheduler.ResizedSide.AtStartTime)
e.Allow = false;
}