expressappframework-404610-event-planning-and-notifications-how-to-access-the-scheduler-control-in-code.md
To access the control in code, create a View Controller and override its OnActivated method. Set the Controller’s ViewController.TargetViewType property to ListView. This way the Controller is activated for List Views only.
File :
YourApplicationName.Blazor.Server\Controllers\SchedulerController.cs
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Blazor;
using DevExpress.ExpressApp.Scheduler.Blazor.Editors;
using DevExpress.Persistent.Base.General;
namespace YourApplicationName.Module.Controllers {
public partial class SchedulerController : ObjectViewController<ListView, IEvent> {
protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
if(View.Editor is SchedulerListEditor schedulerListEditor) {
// Obtain an instance of the DxSchedulerModel type.
schedulerListEditor.SchedulerModel.ActiveViewType = DevExpress.Blazor.SchedulerViewType.WorkWeek;
}
}
}
}
For more information on how to access the Scheduler control in code, refer to the following examples:
File :
YourApplicationName.Win\Controllers\SchedulerController.cs
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Win;
using DevExpress.Persistent.Base.General;
using DevExpress.XtraScheduler;
namespace YourApplicationName.Module.Controllers {
public partial class SchedulerController : ObjectViewController<ListView, IEvent> {
protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
if(View.Editor is SchedulerListEditor schedulerListEditor) {
SchedulerControl scheduler = schedulerListEditor.SchedulerControl;
}
}
}
}
Note
If the CrossThreadFailure error occurs when you handle SchedulerControl events, set the control’s SchedulerOptionsBehavior.UseAsyncMode option to false.
For more information on how to access the Scheduler control in code, refer to the following examples: