Log In
[Expand]Welcome to DevExpress .NET Documentation
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Report Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
  [Expand]Application Solution Components
  [Expand]Business Model Design
  [Expand]Application Model
  [Collapse]UI Construction
    UI Element Overview
    Windows and Frames
    Action Containers
     Ways to Show a View
     List View Column Generation
     List View Columns Customization
     List View Bands Layout
     List View Edit Modes
    [Expand]List View Data Access Modes Overview
     Display Properties of a Referenced Object in the Master Object's View
   [Expand]View Items
    List Editors
    Add and Override Images
    Text Notifications
    Ways to Show a Confirmation Dialog
    ASP.NET Web Application Appearance
    Ways to Customize a Mobile Application
    Application Personalization
    Using a Custom Control that is not Integrated by Default
    XAF Mobile Wrappers for DevExtreme Widgets
  [Expand]Extend Functionality
  [Expand]Data Manipulation and Business Logic
  [Expand]Security System
  [Expand]System Module
  [Expand]Extra Modules
  [Expand]Debugging, Testing and Error Handling
  [Expand]Application Life Cycle
 [Expand]Design-Time Features
 [Expand]Task-Based Help
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Display Properties of a Referenced Object in the Master Object's View

By default, properties of the current object type are displayed in a View. However, you may want to add editors for properties that are exposed by a related object, declared using a reference property. This topic describes the different approaches you can use to display properties of such an associated object.

The following Project and Task business classes are used in this topic.

Although these classes are Entity Framework Code-First entities, you can use the same approaches with XPO persistent classes.

Expanded Apply the ExpandObjectMembers Attribute

When you apply the ExpandObjectMembersAttribute to a reference property, all properties of the related object are added to the model of the List and Detail Views of the current object type.

As a result, all visible properties of the Project class will be added to Task Views (to the Views | <ListView> | Columns and Views | <DetailView> | Items nodes in the Application Model). New columns and View Items are highlighted in red in the image below.

Unnecessary columns/items can be removed in the Model Editor.

You can pass other values of the ExpandObjectMembers enumeration to add Project properties only to Task List Views, or only to Task Detail Views. You can also pass the memberName parameter to add a single specific property instead of all visible properties. For details, refer to the ExpandObjectMembersAttribute class description.

Expanded Add an Editor or Column in the Model Editor

You can add a column/item to a List or Detail View in the Model Editor, using the context menu of Views | <ListView> | Columns and Views | <DetailView> | Items nodes. Use the ReferencePropertyName.PropertyName notation when specifying the IModelMemberViewItem.PropertyName value. In Mobile application, add a new LayoutViewItem to the RowLayout node and set its Id property to this column name to display the column in a ListView. The image below demonstrates how to add the Project.Deadline column to the Task List View in the Model Editor.

You can add a PropertyEditor node to the Views | <DetailView> | Items in a similar manner, but note that you should also add a corresponding layout item to the Views | <DetailView> | Layout node. An example is provided in the Add an Editor to a Detail View tutorial.

Expanded Use the DetailPropertyEditor in a Detail View

You can use the DetailPropertyEditor Property Editor to display a reference property as an embedded Detail View in WinForms and ASP.NET applications. Mobile applications do not support this Property Editor. For this purpose, you can apply the EditorAlias attribute to the reference property.

Alternatively, you can run the Model Editor for the platform-specific project (WinForms or ASP.NET) and set the IModelCommonMemberViewItem.PropertyEditorType property of the BOModel | <Class> | OwnMembers | <Member> node to DetailPropertyEditor.

The image below demonstrates the Project property displayed using the DetailPropertyEditor.

Expanded Add a Calculated Property

You can declare a property whose value is calculated as follows.

You can also add a custom calculated field in the Model Editor and refer to the required property using IModelMember.Expression.

In both these cases, the Deadline property will be readonly in Task Views. If you need to edit it, implement the INotifyPropertyChanged interface and declare Deadline as follows.

In XPO, you do not need to implement INotifyPropertyChanged; the OnChanged protected method is available in the base XPBaseObject class. Additionally, the NonPersistentAttribute is used instead of NotMappedAttribute in XPO.

Expanded See Also

Is this topic helpful?​​​​​​​