How to: Specify a Display Member (for a Lookup Editor, Detail Form Caption, etc.)如何:指定显示成员(用于查找编辑器、详细信息表单标题等)
Each business object used in an XAF application should have a default property. The default property value is treated as a human-readable identifier in an XAF application UI (e.g., FullName of a Contact, Subject of a Task, etc.). Default property values are displayed in the following:
XAF 应用程序中使用的每个业务对象都应具有一个默认属性。在 XAF 应用程序 UI 中,默认属性值被视为人类可读的标识符(例如,联系人的全名、任务主题等)。默认属性值显示在以下内容中:
- Detail View captions;
- the leftmost columns of List Views;
- Lookup List Views;
- Lookup Editors in an unexpanded state.
- 详细信息视图标题;
- 列表视图的最左侧列;
- 查找列表视图;
- 查找处于未展开状态的编辑器。
Default Property of a Business Class
商务舱的默认属性
It is strongly recommended that you apply the XafDefaultPropertyAttribute attribute and pass the default property name to this attribute. The default property must be declared as public and visible (not hidden using the Browsable(false)attribute). If you do not declare a default property, a GUID or Integer identifier may be displayed in the UI. These identifiers are not intended to be seen by end users and may lead to confusion.
强烈建议您应用 XafDefaultProperty 属性属性并将默认属性名称传递给此属性。默认属性必须声明为公共和可见(不使用可浏览(false)属性隐藏)。如果不声明默认属性,则 UI 中可能会显示 GUID 或整数标识符。这些标识符不适合最终用户看到,可能会导致混淆。
using DevExpress.ExpressApp.DC; // ... [XafDefaultProperty(nameof(Subject))] public class Task { // ... public string Subject { get; set; } // ... }
Alternatively, you can use the DefaultProperty attribute from the System.ComponentModel namespace.
或者,您可以使用 System.组件模型命名空间中的 DefaultProperty 属性。
Tip 提示
XAF can detect the default property automatically. If a property name is Name, or it includes the Name substring, then this property is considered default, and there is no need to specify the default property explicitly.
XAF 可以自动检测默认属性。如果属性名称为 Name,或者它包含 Name 子字符串,则此属性被视为默认值,并且无需显式指定默认属性。
Property Displayed in a Lookup Editor
在查找编辑器中显示的属性
The default property of a referenced business object is displayed in a Lookup Property Editor. If you need to use another property in lookups, use the IModelCommonMemberViewItem.LookupProperty property in the Model Editor.
引用的业务对象的默认属性显示在查找属性编辑器中。如果需要在查找中使用其他属性,请使用模型编辑器中的 IModelCommonMemberViewItem.查找属性。
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客户端