ExpandObjectMembersAttribute Class

Specifies whether the target reference property is displayed via several Property Editors representing the referenced object's properties or via a single Lookup or Object Property Editor.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.ExpressApp.v18.2.dll

Declaration

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface, Inherited = true)]
public class ExpandObjectMembersAttribute :
    Attribute,
    _Attribute
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Interface, Inherited:=True)>
Public Class ExpandObjectMembersAttribute
    Inherits Attribute
    Implements _Attribute

XAF can visualize a reference property in two ways. The first way is to display a non-aggregated property via a Lookup Property Editor to allow you to choose the property value by selecting one of the existing objects of the corresponding type; aggregated properties are displayed via an Object Property Editor. The second way is to display several Property Editors representing the referenced object's properties. This way you can customize the referenced object's property values, but you cannot change the reference property value by choosing another object since the Property Editor for the reference property is not displayed.

By default, non-aggregated reference properties are visualized via a Lookup Property Editor. Aggregated reference properties are visualized via several Property Editors representing the referenced object's properties. When the default behavior does not suit your needs, decorate a reference property with ExpandObjectMembersAttribute. Specify how the property must be displayed via the expandingMode parameter in the attribute constructor. There are four possible parameter values. The following example demonstrates their use. Suppose you have the Contact class that exposes the Address reference property of the Address type.

[DefaultClassOptions]
public class Contact : BaseObject {
    public Contact(Session session) : base(session) { }
    public string Name {
        get { return GetPropertyValue<string>("Name"); }
        set { SetPropertyValue<string>("Name", value); }
    }
    public Address Address {
        get { return GetPropertyValue<Address>("Address"); }
        set { SetPropertyValue<Address>("Address", value); }
    }
}
[DefaultClassOptions, DefaultProperty("StreetAddress")]
public class Address : BaseObject {
    public Address(Session session) : base(session) { }
    public string StreetAddress {
        get { return GetPropertyValue<string>("StreetAddress"); }
        set { SetPropertyValue<string>("StreetAddress", value); }
    }
    public string Phone {
        get { return GetPropertyValue<string>("Phone"); }
        set { SetPropertyValue<string>("Phone", value); }
    }
}

If you decorate the Contact.Address property with ExpandObjectMembersAttribute, here is how Contact Views will be affected.

  • ExpandObjectMembers.Always

    [ExpandObjectMembers(ExpandObjectMembers.Always)]
    public Address Address {
    

    The Contact.Name property is displayed alongside the properties declared in the Address class. You cannot assign another object to the Contact.Address property via this UI. All you can do is change the assigned Address object's property values.

    ExpandObjectMemebers.Always

  • ExpandObjectMembers.Never

    [ExpandObjectMembers(ExpandObjectMembers.Never)]
    public Address Address {
    

    The Contact.Name property is displayed alongside the Contact.Address Lookup Property Editor. You can assign another object to the Contact.Address property via this Lookup Property Editor. You cannot directly modify the assigned Address object's property values.

    ExpandObjectMemebers.Never

  • ExpandObjectMembers.InDetailView

    [ExpandObjectMembers(ExpandObjectMembers.InDetailView)]
    public Address Address {
    

    The Contact.Name property is displayed alongside the Contact.Address Lookup Property Editor in List Views. In Detail Views, the Contact.Name property is displayed alongside the properties declared in the Address class.

    ExpandObjectMemebers.InDetailView

  • ExpandObjectMembers.InListView

    [ExpandObjectMembers(ExpandObjectMembers.InListView)]
    public Address Address {
    

    The Contact.Name property is displayed alongside the properties declared in the Address class in List Views. In Detail Views, a Lookup Property Editor is used to represent the Contact.Address property.

    ExpandObjectMemebers.InListView

Inheritance

Object
Attribute
ExpandObjectMembersAttribute

See Also