Back to Devexpress

SchedulerControl.CustomAllowAppointmentCreate Event

wpf-devexpress-dot-xpf-dot-scheduling-dot-schedulercontrol-364ecda9.md

latest7.0 KB
Original Source

SchedulerControl.CustomAllowAppointmentCreate Event

Occurs when an end-user tries to create a new appointment.

Namespace : DevExpress.Xpf.Scheduling

Assembly : DevExpress.Xpf.Scheduling.v25.2.dll

NuGet Package : DevExpress.Wpf.Scheduling

Declaration

csharp
public event AppointmentItemOperationEventHandler CustomAllowAppointmentCreate
vb
Public Event CustomAllowAppointmentCreate As AppointmentItemOperationEventHandler

Event Data

The CustomAllowAppointmentCreate event's data class is AppointmentItemOperationEventArgs. The following properties provide information specific to this event:

PropertyDescription
AllowGets or sets whether performing a particular action is allowed.
AppointmentGets the appointment for which the element is raised. Inherited from AppointmentItemEventArgs.
RecurringGets whether the target appointment is recurring.

Remarks

Handle the CustomAllowAppointmentCreate event and sets its AppointmentItemOperationEventArgs.Allow property to manage a particular case and specify whether to allow an end-user to create a new appointment. If you do not specify the required behavior manually, the SchedulerControl.AllowAppointmentCreate manages whether creating new appointments is allowed.

The appointment to be created can be accessed using the AppointmentItemEventArgs.Appointment property.

Set the AppointmentItemOperationEventArgs.Allow property to false to prevent an appointment from being created.

Note

The SchedulerControl uses the CommandManager class to manage commands executed by the ribbon or context menu items. The RequerySuggested event is fired when any changes that can affect the command’s ability to execute (e.g., change of focus) have been made. It notifies the command that is should raise the CanExecuteChanged event, which makes the CustomAllowAppointmentCreate event to fire as well. This chain of events can occur involuntarily, so make sure that the event handler does not contain any code that may slow the application performance.

Example

View Example

csharp
private void schedulerControl1_CustomAllowAppointmentCreate(object sender, AppointmentItemOperationEventArgs e)
{
    //Retrieve the selected interval:
    DateTimeRange selectedIntervalRange = schedulerControl1.SelectedInterval;
    TimeInterval selectedInterval = new TimeInterval(selectedIntervalRange.Start, selectedIntervalRange.End);

    //Check whether the selected interval intersects with the resticted interval:
    //If true, restrict appointment creation 
    e.Allow = IsIntervalAllowed(selectedInterval);
}
vb
Private Sub schedulerControl1_CustomAllowAppointmentCreate(ByVal sender As Object, ByVal e As AppointmentItemOperationEventArgs)
    'Retrieve the selected interval:
    Dim selectedIntervalRange As DateTimeRange = schedulerControl1.SelectedInterval
    Dim selectedInterval As New TimeInterval(selectedIntervalRange.Start, selectedIntervalRange.End)

    'Check whether the selected interval intersects with the resticted interval:
    'If true, restrict appointment creation 
    e.Allow = IsIntervalAllowed(selectedInterval)
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomAllowAppointmentCreate event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-scheduler-apply-end-user-restrictions/CS/WpfApplication1/MainWindow.xaml#L20

xml
CustomAllowAppointmentConflicts="customAllowAppointmentConflictsHandler"
                    CustomAllowAppointmentCreate="customAllowAppointmentCreateHandler">
<!--endregion #main-->

wpf-scheduler-apply-end-user-restrictions/CS/WpfApplication1/obj/Debug/net8.0-windows/MainWindow.g.cs#L133

csharp
#line 20 "..\..\..\MainWindow.xaml"
this.schedulerControl1.CustomAllowAppointmentCreate += new DevExpress.Xpf.Scheduling.AppointmentItemOperationEventHandler(this.customAllowAppointmentCreateHandler);

wpf-scheduler-apply-end-user-restrictions/VB/WpfApplication1/obj.NetFX/x86/Debug/MainWindow.g.vb#L128

vb
#ExternalSource("..\..\..\MainWindow.xaml",20)
AddHandler Me.schedulerControl1.CustomAllowAppointmentCreate, New DevExpress.Xpf.Scheduling.AppointmentItemOperationEventHandler(AddressOf Me.customAllowAppointmentCreateHandler)

See Also

SchedulerControl Class

SchedulerControl Members

DevExpress.Xpf.Scheduling Namespace