Reuse Implemented Functionality
- 3 minutes to read
This topic describes how to add optional modules to extend application functionality.
An XAF application consists of user-defined and standard XAF modules.
Modules can be platform-agnostic or platform-dependent. Platform-agnostic modules use framework features that are not specific to any platform and work on different platforms with the same code base. You can build applications for different platforms based on the same business logic if the applications refer to the same set of platform-agnostic modules.
You can extend or modify an XAF module, use third-party modules, or create your own reusable modules.
Implement Property Value Validation
Follow the steps below to add the Validation module to your application and set up validation rules for entity objects.
Add the DevExpress.ExpressApp.Validation.Blazor NuGet package to the SimpleProjectManager.Blazor.Server project and the DevExpress.ExpressApp.Validation.Win NuGet package to the SimpleProjectManager.Win project. See the following topic for more information on how to install DevExpress NuGet packages: Choose Between Offline and Online DevExpress NuGet Feeds.
In the MySolution.Blazor.Server project, open the Startup.cs file and add the Validation module to the application builder. Do the same in the Startup.cs file of the MySolution.Win project:
public class Startup { // ... public void ConfigureServices(IServiceCollection services) { // ... services.AddXaf(Configuration, builder => { builder.UseApplication<MySolutionBlazorApplication>(); builder.Modules // ... .AddValidation(); // ... }); // ... } }
Open the SimpleProjectManager.Module\BusinessObjects\ProjectTask.cs file and apply the RuleCriteriaAttribute to the
ProjectTask
class:using DevExpress.Persistent.Validation; // ... [RuleCriteria("EndDate >= StartDate", CustomMessageTemplate = "Start Date must be less than End Date")] public class ProjectTask : BaseObject { // ... }
Run the application and change the task’s end date. When you save the changes, XAF validates the task according to specified settings.
- ASP.NET Core Blazor
- Windows Forms
Highlight Property Editors
Follow the steps below to add the Conditional Appearance module to your application and highlight all tasks whose status is “In progress”.
Add the DevExpress.ExpressApp.ConditionalAppearance NuGet package to the SimpleProjectManager.Module project.
In the Solution Explorer, go to the SimpleProjectManager.Module project and open the Module.cs file. Add the Conditional Appearance module to the RequiredModuleTypes collection.
using DevExpress.ExpressApp; using DevExpress.ExpressApp.Updating; namespace SimpleProjectManager.Module; public sealed class SimpleProjectManagerModule : ModuleBase { public SimpleProjectManagerModule() { // ... RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.ConditionalAppearance.ConditionalAppearanceModule)); } // ... }
Open the
ProjectTask
class and applyAppearanceAttribute
as displayed in the code sample below:// ... using DevExpress.ExpressApp.ConditionalAppearance; namespace SimpleProjectManager.Module.BusinessObjects { // ... [Appearance("InProgress", TargetItems = "Subject;AssignedTo", Criteria = "Status = 1", BackColor = "LemonChiffon")] public class ProjectTask : BaseObject { // ... } // ... }
Run the application. The task whose status is “In progress” is highlighted now.
- ASP.NET Core Blazor – List View
- ASP.NET Core Blazor – Detail View
- Windows Forms – List View
- Windows Forms – Detail View