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.查找属性。