The requested page is not available for the requested platform. You are viewing the content for Default platform.

Type Properties

  • 5 min to read

In XAF, properties of the System.Type type can be displayed in a combo box editor that lists the available object types in WinForms and ASP.NET applications or in a pop-up dialog in Mobile applications.

Examples

WinForms Property Editors for System.Type Properties

Each WinForms Property Editor has a control that displays a corresponding property in a Detail View, and a repository item that displays a property in a List Editor that supports in-place editing. Both the control and repository item are shown below.

TypePropertyEditor

Control: ImageComboBoxEdit editor from the XtraEditors Library.

Repository Item: RepositoryItemImageComboBox item from the XtraEditors Library.

Description:

Used for Type properties by default.

When declaring a Type property that is displayed using the TypePropertyEditor, apply the System.ComponentModel.TypeConverter attribute to it. In the attribute, pass the type of the converter that returns a collection of values representing data types in the Property Editor. For instance, pass a built-in LocalizedClassInfoTypeConverter, which returns Caption property values for the corresponding BOModel | <Class> nodes.

If you do not use the TypeConverter attribute for a type property, a string representation of found types is loaded to the editor's Items collection.

Use Alt + Down Arrow to expand the TypePropertyEditor's drop-down window.

VisibleInReportsTypePropertyEditor

Control: ImageComboBoxEdit editor from the XtraEditors Library.

Repository Item: RepositoryItemImageComboBox item from the XtraEditors Library.

Description:

Inherited from the TypePropertyEditor. Used by the Pivot Chart Module and Reports V2 Module. It lists the types of business classes that have the VisibleInReports property of the Application Model's IModelClass node set to true.

ASP.NET Property Editors for System.Type Properties

Each ASP.NET Property Editor has controls that display a property in a Detail View's View and Edit mode (see DetailView.ViewEditMode). These controls are listed below.

ASPxTypePropertyEditor

View mode control: System.Web.UI.WebControls.Label.

Edit mode control: ASPxComboBox editor from the ASPxEditors Library.

Description:

Used for Type properties by default.

When declaring a Type property that is displayed using the TypePropertyEditor, apply the System.ComponentModel.TypeConverter attribute to it. In the attribute, pass the type of the converter that returns a collection of values representing data types in the Property Editor. For instance, pass a built-in LocalizedClassInfoTypeConverter. It returns values of the Caption property of the corresponding BOModel | <Class> nodes.

If you do not use the TypeConverter attribute for a type property, a string representation of found types is loaded to the editor's Items collection.

To expand the editor's drop-down window, use Alt + Down Arrow.

ASPxVisibleInReportsTypePropertyEditor

View mode control: System.Web.UI.WebControls.Label.

Edit mode control: ASPxComboBox editor from the ASPxEditors Library.

Description:

Inherited from ASPxTypePropertyEditor. Used by the Pivot Chart Module and Reports V2 Module. It lists the types of business classes that have the VisibleInReports property of the Application Model's IModelClass node set to true.

Mobile Property Editor for System.Type Properties

Each Mobile Property Editor has widgets that display a property in a Detail View's View and Edit mode (see DetailView.ViewEditMode). These widgets are listed below.

MobileTypePropertyEditor

View mode control: Label that displays text using the div HTML element.

Edit mode control: Lookup that uses the dxLookup widget.

Description:

Used for Type properties by default.

When declaring a Type property that is displayed using the MobileTypePropertyEditor, apply the System.ComponentModel.TypeConverter attribute to it. In the attribute, pass the type of the converter that returns a collection of values representing data types in the Property Editor. For instance, pass a built-in LocalizedClassInfoTypeConverter. It returns values of the Caption property of the corresponding BOModel | <Class> nodes.

If you do not use the TypeConverter attribute for a type property, a string representation of found types is loaded to the editor's Items collection.

Customize the Types List

Type Property Editors use the LocalizedClassInfoTypeConverter type converter to create the list of values displayed in the editor's combo box. By default, this converter returns persistent types only. To add all registered non-persistent types to this collection, inherit LocalizedClassInfoTypeConverter, modify the AllowAddNonPersistentObjects field value and pass the custom converter to the TypeConverter attribute type.

using DevExpress.Persistent.Base;
// ...
public class MyLocalizedClassInfoTypeConverter : LocalizedClassInfoTypeConverter {
    public MyLocalizedClassInfoTypeConverter() {
        AllowAddNonPersistentObjects = true;
    }
}
[TypeConverter(typeof(MyLocalizedClassInfoTypeConverter))]
public Type DataType { get; set;}

Override the AddCustomItems method in your custom converter to add specific types to the collection.

public override void AddCustomItems(List<Type> list) {
   list.Add(typeof(MyType));
   list.Sort(this);
   base.AddCustomItems(list);
}

Override the GetSourceCollection method to create the entire collection manually.

public override List<Type> GetSourceCollection(ITypeDescriptorContext context) {
    List<Type> result = new List<Type>();
    // Populate the 'result' list here...
    return result;
}
Tip

More customization approaches are provided in the How to hide or filter out certain types from the drop-down editor for the System.Type properties knowledge base article.