Reuse Implemented Functionality 重用实现功能
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解决方案为每个应用程序包含一个平台无关的(共享的)模块和平台相关的模块。本主题描述如何将外部库中的额外模块和业务对象添加到共享模块以扩展应用程序的功能。
XAF Extra Modules
XAF额外的模块
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.
使用模块设计器或应用程序设计器添加或删除额外的模块。双击Module.cs (Module.vb)文件,从模块项目调用模块设计器。要调用应用程序设计器,双击应用程序项目中的WinApplication.cs (WinApplication.vb)或WebApplication.cs (WebApplication.vb)文件。
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.
按照以下步骤将条件外观和验证模块添加到共享模块,并设置它们与业务对象的交互方式。
- Invoke the Module Designer for the shared module in the SimpleProjectManager.Module project.
-
Drag the Conditional Appearance and Validation modules from the Toolbox to the designer's Required Modules section.
为SimpleProjectManager中的共享模块调用模块设计器。模块项目。
.将“条件外观”和“验证”模块从“工具箱”拖动到“设计器所需的模块”部分。
-
Open the SimpleProjectManager.Module\BusinessObjects\Planning.cs(vb) file. Apply the AppearanceAttribute and RuleCriteriaAttribute to the ProjectTask class, as demonstrated below:
打开SimpleProjectManager.Module\BusinessObjects\ plan .cs(vb)文件。将外观属性和RuleCriteriaAttribute应用到ProjectTask类,如下所示:
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 { // ... }
-
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.
运行WinForms或ASP。NET应用程序并创建多个项目任务。添加的模块根据指定的设置影响应用程序的外观和验证逻辑。
Note
Some built-in XAF modules integrate the DevExpress WinForms
and ASP.NET 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.
请注意
一些内置的XAF模块集成了DevExpress WinForms
和ASP。NET可视化组件到您的应用程序中。例如,XAF为常见的业务场景提供了一些模块,包括数据网格和编辑器、导航、菜单和布局、报告、图表、数据透视网格、树视图、日历和调度器
等。有关更多信息,请参阅额外的模块教程。
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.
您可以从业务类库向应用程序添加业务类。XAF根据这个类的结构生成UI元素。以下步骤演示如何从业务类库添加Person类,并创建Employee导航项以在列表中显示Person对象。
- In the Solution Explorer, double-click the Module.cs (Module.vb) file in the SimpleProjectManager.Module project to invoke the Module Designer.
-
In the Exported Types section, expand the Referenced Assemblies | DevExpress.Persistent.BaseImpl.v19.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.
在解决方案资源管理器中,双击SimpleProjectManager中的Module.cs (Module.vb)文件。调用模块设计器的模块项目。
在export Types部分,展开引用的程序集| devexpress . persistence . baseimpl .v19.2节点。应用程序模型中包含的类以粗体标记。Person节点用粗体标记,因为应用程序模型有ProjectTask。AssignedTo和项目。此类型的管理器属性。
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.
请注意
要导出类型,请选择相应的类并按Space或右键单击该类,然后在调用的上下文菜单中选择Use type in Application。在模块设计器中进行更改后重新生成项目。
-
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.
- 调用SimpleProjectManager的模型编辑器。模块项目和导航到NavigationItems |项|规划|项节点。创建一个新的导航项,并将其标题属性设置为“Employee”,将视图设置为“Person_ListView”。有关如何添加导航项的更多信息,请参阅导航控件主题中的“添加项”。
-
- Run an application. The navigation control shows the new item in the Planning section.
- 运行一个应用程序。导航控件在Planning部分显示新项。
-
Note
You can also use third-party modules
or create your own reusable modules for use in multiple XAF applications.
请注意
您还可以使用第三方模块
或者创建自己的可重用模块,以便在多个XAF应用程序中使用。
XAF开发成品案例参考
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。
作者博客: http://www.cnblogs.com/foreachlife
欢迎加入CIIP框架\XAF技术应用交流群: 336090194 群文件中有更多相关工具及文档资料
转载请注明出处。多谢!
欢迎加我微信: admiralcn 或扫码:

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端