Reuse Implemented Functionality

In the previous lessons (Define the Logical Data Model and Relationships and Customize the Application UI and Behavior), you implemented the business model, added several Application Model customizations, and added a custom Action that executes some logic triggered by a user. All of this functionality is located in the shared SimpleProjectManager.Module project. Since this project is an XAF module, it enables you to easily reuse the functionality implemented in other XAF applications.

XAF Extra Modules

Technically, an XAF application consists of "building blocks": user-defined XAF modules and standard XAF modules (Extra Modules). Here are some important facts about XAF modules.

  • Modules can be platform-agnostic or platform-dependent Desktop and Web modules. Platform-agnostic modules make use of framework features that are not specific to any platform, and thus will work on different platforms with the same code base.
  • Applications for different platforms can be built based on the same business logic if they refer to the same set of platform-agnostic modules.
  • You can extend or modify an XAF module if it does not completely satisfy your requirements.
  • You can use third-party modules.
  • You can create your own reusable modules for use in multiple XAF applications.

To manage modules, the Module Designer and Application Designer are used. The Module Designer can be invoked from your custom module by double-clicking the Module.cs (Module.vb) file. In this designer, you can add and remove other modules that are required by the current module. The Application Designer is intended for a similar purpose, but it targets the executable application project instead of the module.

Follow the steps below to add the Conditional Appearance and Validation Module standard modules to your shared module.

  1. In the SimpleProjectManager.Module project, double-click the Module.cs (Module.vb) file to invoke the Module Designer.
  2. Drag the Conditional Appearance and Validation modules from the Toolbox to the Required Modules section of the designer.


  3. Open the SimpleProjectManager.Module\BusinessObjects\Planning.cs(vb) file. Apply the AppearanceAttribute and RuleCriteriaAttribute attributes to the ProjectTask class, as demonstrated in the snippet 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 {
        // ...

Now you can run the application and create several project tasks to see that they are colored and validated according to the settings specified in the code above.



Certain built-in XAF modules seamlessly integrate the DevExpress WinForms and ASP.NET visual components into your XAF application. This integration provides an easier approach (in comparison to a traditional approach using standard Visual Studio controls) for XAF developers to build applications with features found in common controls. For instance, common business scenarios are implemented for the data grid and editors, navigation, menu and layout, reporting, charting, pivot grid, tree view, calendar and scheduling, etc. See the Extra Modules tutorial for additional information.

Data Models from External Libraries

You can add business classes for your application using the Business Class Library or any other assembly that contains business classes. The external classes will be recognized by XAF, and the corresponding UI elements will be generated according to their structure. Follow the steps below to add the Employee navigation item, which will invoke the Business Class Library's Person object list.

  • In the Solution Explorer, find the Module.cs (Module.vb) file in the MySolution.Module project. Double-click it to invoke the Module Designer.
  • In the Exported Types section, locate the Referenced Assemblies | DevExpress.Persistent.BaseImpl.v18.2 | Person node. It is marked in bold because this class was used earlier as a type for the ProjectTask.AssignedTo and Project.Manager fields. Bold font means that the business class will be added to the Application Model, a corresponding table will be created for it in the database, and the class will take part in the UI construction process.



    To export a type, select the corresponding class and press the Space bar, or right-click it and choose Use Type in Application in the invoked context menu. Rebuild the project if you have changed something in the Module Designer.

  • Once the business class is part of the Application Model, you can show it in the UI. In the NavigationItems | Items | Planning | Items group of Model Editor invoked for SimpleProjectManager.Module project, create a new navigation item with the Caption property assigned to "Employee" and the View property assigned to "Person_ListView". Refer to the Add an Item to the Navigation Control tutorial for details.
  • Run your application. Notice the new item in the Planning section of the navigation control.



If you experience any problems while following these steps, or you just want to let us know what you think, contact our support team (full and free technical support during the evaluation period is included).

Next topic: Summary

See Also