Skip to main content
A newer version of this page is available.

Reuse Implemented Functionality

  • 4 minutes to read

A default XAF solution contains one platform-agnostic (shared) module and platform-dependent modules for each application. This topic describes how to add extra modules and business objects from an external library to the shared module to extend the applications’ functionality.

XAF Extra Modules

Use the Module Designer or Application Designer to add or remove extra modules. Double-click the Module.cs (Module.vb) file to invoke the Module Designer from a module project. To invoke the Application Designer, double-click the WinApplication.cs (WinApplication.vb) or WebApplication.cs (WebApplication.vb) file in an application project.

Follow the steps below to add the Conditional Appearance and Validation module to the shared module and set up how they interact with the business objects.

  1. Invoke the Module Designer for the shared module in the SimpleProjectManager.Module project.
  2. Drag the Conditional Appearance and Validation modules from the Toolbox to the designer’s Required Modules section.

    SPM_Modules

  3. Open the SimpleProjectManager.Module\BusinessObjects\Planning.cs(vb) file. Apply the AppearanceAttribute and RuleCriteriaAttribute to the ProjectTask class, as demonstrated below:

    using DevExpress.ExpressApp.ConditionalAppearance;
    using DevExpress.Persistent.Validation;
    using System.Drawing;
    // ...
    [Appearance("Completed1", TargetItems = "Subject", 
        Criteria = "Status = 'Completed'", FontStyle = FontStyle.Strikeout, FontColor = "ForestGreen")]
    [Appearance("Completed2", TargetItems = "*;Status;AssignedTo", 
        Criteria = "Status = 'Completed'", Enabled = false)]
    [Appearance("InProgress", TargetItems = "Subject;AssignedTo", 
        Criteria = "Status = 'InProgress'", BackColor = "LemonChiffon")]
    [Appearance("Deferred", TargetItems = "Subject", 
        Criteria = "Status = 'Deferred'", BackColor = "MistyRose")]
    [RuleCriteria("EndDate >= StartDate")]
    public class ProjectTask : BaseObject {
        // ...
    }
    
  4. Run the WinForms or ASP.NET application and create several project tasks. The added modules affect the applications’ appearance and validation logic according to the specified settings.

    SPM_ModulesRuntime

Note

Some built-in XAF modules integrate the DevExpress WinForms and ASP.NET Web Forms visual components into your application. For example, XAF provides modules for common business scenarios with the data grid and editors, navigation, menu and layout, report, chart, pivot grid, tree view, calendar and scheduler, etc. Refer to the Extra Modules tutorial for more information.

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. In the Solution Explorer, double-click the Module.cs (Module.vb) file in the SimpleProjectManager.Module project to invoke the Module Designer.
  2. In the Exported Types section, expand the Referenced Assemblies | DevExpress.Persistent.BaseImpl.v20.2 node. Classes included in the Application Model are marked in bold. The Person node is marked in bold because the Application Model has ProjectTask.AssignedTo and Project.Manager properties of this type.

    Basic_Exported_types

    Note

    To export a type, select the corresponding class and press Space or right-click this class and choose Use Type in Application in the invoked context menu. Rebuild the project after you made changes in the Module Designer.

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

    Basic_Navigation_Item

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

    Basic_Employee

Note

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

See Also