Skip to main content

Reuse Implemented Functionality

  • 2 minutes to read

This topic describes how to add additional modules and business objects from an external library to extend the application’s functionality.

XAF Extra Modules

Follow the steps below to add the Validation module and set up validation rules for business objects.

  1. In the Solution Explorer, right-click the SimpleProjectManager.Blazor.Server project and select Manage NuGet Packages. In the invoked NuGet Package Manager, choose the DevExpress 22.1 Local package source and install the DevExpress.ExpressApp.Validation and DevExpress.ExpressApp.Validation.Blazor NuGet packages.

    Add the NuGet Package to the shared project

  2. Open the SimpleProjectManager.Blazor.Server\Module.cs file and add the following code to the Module constructor:

    using DevExpress.ExpressApp.Validation;
    // ...
    namespace SimpleProjectManager.Blazor.Server {
        public sealed partial class SimpleProjectManagerBlazorModule : ModuleBase {
            public SimpleProjectManagerBlazorModule() {
                // ...
  3. Open the SimpleProjectManager.Module\BusinessObjects\Planning.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 ASP.NET Core Blazor application and create several project tasks. The added module validates project tasks according to the specified settings.

    Invalid values

Data Models from External Libraries

You can add a business class to your application from the Business Class Library. XAF generates UI elements according to this class’ structure. The following steps show how to add the Person class from the Business Class Library and create the Employee navigation item to display Person objects in a list.

  1. Open the SimpleProjectManager.Module\Module.cs file and add the following code to the Module constructor:

    using DevExpress.Persistent.BaseImpl;
    // ...
    namespace SimpleProjectManager.Module {
        public sealed partial class SimpleProjectManagerModule : ModuleBase {
            public SimpleProjectManagerModule() {
                // ...
  2. Invoke the Model Editor for the SimpleProjectManager.Module project and navigate to the NavigationItems | Items | Planning | Items node. Create a new navigation item and set its Caption property to “Employee” and View to “Person_ListView”. Refer to the Add an Item to the Navigation Control topic for more information on how to add a navigation item.

    The new navigation item in the Model Editor

  3. Run the application. The navigation control shows the new item in the Planning section.

    The Person Detail and List Views


You can also use third-party modules or create your own reusable modules for use in multiple XAF applications.

See Also