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

Frame.SetView(View) Method

Sets a specified View for the current Frame.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v18.2.dll

Declaration

public bool SetView(
    View view
)

Parameters

Name Type Description
view View

A View object that is set for the current Frame.

Returns

Type Description
Boolean

true, if an old View can be changed by another one; otherwise, false.

Remarks

Use the SetView method to set a specified View for the current Frame. This method deactivates all Controllers, sets a specified View for the Frame and then re-activates Controllers. Then, if a Template is set for the Frame, the new View is set for this Template (IFrameTemplate.SetView).

Before deactivating and after activating Controllers, the Frame.ViewChanging and Frame.ViewChanged events are raised, respectively. Handle these events to perform specific actions before and after setting a View.

If a View is already set for the Frame, the SetView method replaces it with a new one, raises an old View’s View.Closed event, and then disposes it.

To create a View and pass it to the SetView method, use the XafApplication.CreateListView, XafApplication.CreateDetailView and XafApplication.CreateDashboardView methods. Refer to the Ways to Show a View topic for additional information.

The following example demonstrates how to show a View in the main window when a record is selected in a pop-up window. Note that this approach will not work in the MDI mode, since the main window cannot contain a View in this mode.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
//...
public class ShowPersonController : ViewController {
    public ShowPersonController() {
        PopupWindowShowAction showPersonAction = new 
            PopupWindowShowAction(this, "ShowPerson", PredefinedCategory.View);
        showPersonAction.CustomizePopupWindowParams += 
            showPersonAction_CustomizePopupWindowParams;
        showPersonAction.Execute += showPersonAction_Execute;
    }
    void showPersonAction_CustomizePopupWindowParams(object sender, 
    CustomizePopupWindowParamsEventArgs e) { 
        IObjectSpace newObjectSpace = Application.CreateObjectSpace(typeof(Person));
        e.View = Application.CreateListView(newObjectSpace, typeof(Person), true);
        e.DialogController.AcceptAction.SelectionDependencyType = 
            SelectionDependencyType.RequireMultipleObjects;
    }
    void showPersonAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) {
        Person selectedPerson = (Person)e.PopupWindowViewCurrentObject;
        IObjectSpace newObjectSpace = Application.CreateObjectSpace(typeof(Person));
        DetailView personDetailView = Application.CreateDetailView(newObjectSpace, 
            newObjectSpace.GetObject<Person>(selectedPerson));
        personDetailView.ViewEditMode = DevExpress.ExpressApp.Editors.ViewEditMode.Edit;
        e.PopupWindow.Close(true);
        Application.MainWindow.SetView(personDetailView);
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetView(View) method.

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