Back to Devexpress

ViewController.TargetViewType Property

expressappframework-devexpress-dot-expressapp-dot-viewcontroller-a245972e.md

latest4.1 KB
Original Source

ViewController.TargetViewType Property

Specifies the type of the View, for which a View Controller is intended.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
[DefaultValue(ViewType.Any)]
public ViewType TargetViewType { get; set; }
vb
<DefaultValue(ViewType.Any)>
Public Property TargetViewType As ViewType

Property Value

TypeDefaultDescription
ViewTypeAny

A ViewType enumeration value identifying a View type.

|

Available values:

NameDescription
Any

An Action or a View Controller will be activated in Frames (Windows) with any Views.

| | DetailView |

An Action or a View Controller will be activated in Frames (Windows) with Detail Views.

| | ListView |

An Action or a View Controller will be activated in Frames (Windows) with List Views.

| | DashboardView |

An Action or a View Controller will be activated in Frames (Windows) with Dashboard Views.

|

Remarks

View Controllers can be activated for both List and Detail Views. You can use the TargetViewType property to provide View Controller activation within the List, Detail, or any type of View.

Note

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

Alternatively, you can implement the generic ViewController<ViewType> Controller instead of the ViewController and specify the View’s type, for which this Controller is intended, in the ViewType generic parameter. In this case, you do not need to perform an additional cast when you access the View.

The example below demonstrates how to add a PopupWindowShowAction to all List Views in an application.

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

See Also

TargetObjectType

TargetViewId

TargetViewNesting

Define the Scope of Controllers and Actions

ViewController Class

ViewController Members

DevExpress.ExpressApp Namespace