Skip to main content
A newer version of this page is available. .

ViewController.TargetObjectType Property

Specifies a ViewController‘s target object type. The View Controller is activated only for Views that represent this type.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.1.dll

Declaration

[TypeConverter(typeof(BusinessClassTypeConverter<object>))]
[DefaultValue(null)]
public Type TargetObjectType { get; set; }

Property Value

Type Default Description
Type *null*

An object’s type.

Remarks

View Controllers are activated for both Windows and Frames. However, you can specify the type of objects represented by a View to provide a View Controller activation. For this purpose, specify the TargetObjectType property in code or the Designer.

To make a single View Controller available in Views of different business object types simultaneously, set the TargetObjectType property in code to an interface or their base class type, which is implemented or inherited by all these business types respectively. Also, for the same task, you can specify several View identifiers using the ViewController.TargetViewId property.

Note

The TargetObjectType property affects only ViewController’s activation. Controller.FrameAssigned and other events that are irrelevant to the object type always fire.

The following example creates a List View and displays it via a PopupWindowShowAction.

using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
// ...
public class ShowListViewController : ViewController {
    public ShowListViewController() {
        PopupWindowShowAction showListViewAction = new PopupWindowShowAction(this, "ShowListView",
            PredefinedCategory.Edit);
        this.TargetObjectType = typeof(Note);
        showListViewAction.CustomizePopupWindowParams += ShowListViewAction_CustomizePopupWindowParams;
    }
    private void ShowListViewAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) {
        Type objectType = typeof(Person);
        e.View = Application.CreateListView(objectType, true);
    }
}

Alternatively, you can implement the generic ObjectViewController<ViewType, ObjectType> Controller instead of the ViewController and specify the View and object type for which this Controller should be activated in the ViewType and ObjectType generic parameters.

The following code snippets (auto-collected from DevExpress Examples) contain references to the TargetObjectType property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also