Skip to main content

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.

  1. 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.

  2. 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();
                // ...
            });
            // ...
        }
    }
    
  3. 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 {
        // ...
    }
    
  4. 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
    ASP.NET Core Blazor Validation, DevExpress
    Windows Forms
    Windows Forms Validation, DevExpress

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”.

  1. Add the DevExpress.ExpressApp.ConditionalAppearance NuGet package to the SimpleProjectManager.Module project.

  2. 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));
        }
    
        // ...
    }
    
  3. Open the ProjectTask class and apply AppearanceAttribute 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
        {
            // ...
        }
    
        // ...
    }
    
  4. Run the application. The task whose status is “In progress” is highlighted now.

    ASP.NET Core Blazor – List View
    The ASP.NET Core Blazor conditional appearance in a List View, DevExpress
    ASP.NET Core Blazor – Detail View
    The ASP.NET Core Blazor conditional appearance in a Detail View, DevExpress
    Windows Forms – List View
    The Windows Forms conditional appearance in a List View, DevExpress
    Windows Forms – Detail View
    The Windows Forms conditional appearance in a Detail View, DevExpress
See Also