Scheduler List Views work with events (IEvent
objects) and resources (IResource
objects).
XAF's Business Class Library implements these interfaces in Event
and Resource
classes. In some cases, you may need to extend these classes or even implement their corresponding interfaces from scratch.
The example in this repository implements the following scenarios:
NOTE
Instructions below describe classes specific to Entity Framework Core ORM. For XPO-specific classes refer to the following files:
- "c:\Program Files\DevExpress 2X.Y\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.Xpo\Event.cs"
- "c:\Program Files\DevExpress 2X.Y\Components\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl.Xpo\Resource.cs"
-
Create a new event class and add properties. See the #region Base Properties section in the source code. It contains all
IEvent
properties exceptResourceId
. -
Implement a resource object. See the #region Resources section in the source code.
The
IEvent
interface requires a stringResourceId
property that stores a collection of resources in an XML string (required by the Scheduler control). In XAF, we recommend that you add an associated collection of objects instead. Add theResourceId
string property and theResources
collection property and set up synchronization between them. -
Implement
IRecurrentEvent
. See the #region IRecurrentEvent section in the source code. -
Implement
IReminderEvent
. See the #region IReminderEvent section in the source code.Note Reminders are currently not supported in XAF Scheduler Module for ASP.NET Core Blazor. Skip this section for ASP.NET Core Blazor applications.
-
Add Blazor compatibility options. See the #region Blazor compatibility section in the source code. Skip this step if you do not plan to implement the
Event
class in an ASP.NET Core Blazor application. -
Implement object construction. See the #region Construction section in the source code.
If you need to initialize a property (for example the
StartOn
orEndOn
property) when XAF creates a newCustomEvent
, override theOnCreated
event. -
If you want to add validation, see the #region Validation section in the source code.
To use the Validation Module, add validation rules to your object. For example, you can demand that the
StartOn
date always precedes theEndOn
date.
-
Implement the
IResource
interface in theApplicationUser
class.Note
In this example, we implementIResource.Id
explicitly becauseApplicationUser
already has anID
property. This implicit implementation causes an ambiguous exception in Windows Forms applications that use Entity Framework Core ORM. To resolve this issue, remap the Scheduler to theID
property directly instead of theIResource.Id
property. For implementation details, refer to CustomEventWithUserResourcesController.cs. -
If you implement
IResource
in multiple classes, specify a Resource class for the corresponding Scheduler List View. For more information, refer to the following topic: Use a Custom Resource Class.
-
Enable drag-and-drop in Scheduler.
By default, Scheduler does not allow to edit objects. You need to set the AllowEdit property to
true
in the Model.DesignedDiffs.xafml file. -
Customize the
Start
andEnd
properties to show time.By default,
DateTime
property editors only display date. ChangeDisplayFormat
andEditMask
to show and edit time. For details, see the Model.DesignedDiffs.xafml file.
-
If you want to create a One-to-Many relationship between a resource and events, change
ResourceId
implementation. For details, see the following source file: CustomEventWithCustomResource.cs. -
Create a custom
Resource
class and implement theIResource
interface. For implementation details, see the following source file: CustomResource.cs.
- CustomEventWithUserResources.cs
- ApplicationUser.cs
- CustomEventWithUserResourcesController.cs
- CustomResource.cs
- CustomEventWithCustomResource.cs
(you will be redirected to DevExpress.com to submit your response)