The SchedulerControl allows you to prohibit the user to create or edit (delete, drag, etc.) appointments shown within the scheduling area. With the restriction applied, all corresponding UI elements, such as ribbon and popup menu items, are disabled.
Use AllowAppointments... properties to prohibit a specific action for all appointments. Handle the corresponding CustomAllow... event to define custom logic to allow the user to perform an action.
The SchedulerControl uses the CommandManager class to manage commands the ribbon or context menu items execute. The RequerySuggested event is fired when any changes that can affect the command's ability to execute (for example, changing focus) are made. It notifies the command that it should raise the CanExecuteChanged event, which makes some CustomAllow... events fire as well. This chain of events can occur involuntarily, so make sure that the event handler does not contain any code that may affect the application's performance.
All the available properties and their corresponding events are listed below. These are all dependency properties.
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);
private void schedulerControl1_CustomAllowAppointmentConflicts(object sender, AppointmentItemConflictEventArgs e)
//Obtain the selected interval:
TimeInterval interval = e.Interval;
//If the appointment is to be moved to the restricted time interval,
//Add the dragged appointment the conflicting appointments collection:
//This method is used to check
//whether the target interval intersects with the resticted interval:
private bool IsIntervalAllowed(TimeInterval interval)
DateTime dayStart = interval.Start.Date;
while (dayStart < interval.End)
dayStart = dayStart.AddDays(1);
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)
Private Sub schedulerControl1_CustomAllowAppointmentConflicts(ByVal sender As Object, ByVal e As AppointmentItemConflictEventArgs)
'Obtain the selected interval:
Dim interval As TimeInterval = e.Interval
'If the appointment is to be moved to the restricted time interval,
'Add the dragged appointment the conflicting appointments collection:
If Not IsIntervalAllowed(interval) Then
'This method is used to check
'whether the target interval intersects with the resticted interval:
Private Function IsIntervalAllowed(ByVal interval As TimeInterval) As Boolean
Dim dayStart As Date = interval.Start.Date
Do While dayStart < interval.End
If interval.IntersectsWithExcludingBounds(lunchTime) Then
dayStart = dayStart.AddDays(1)
Was this page helpful?
Thanks for your feedback! Any other suggestions? Tell us here.