Frame.SetView(View, Boolean, Frame, Boolean) Method

Sets a specified View for the current Frame.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v18.1.dll

Declaration

public bool SetView(
    View view,
    bool updateControllers,
    Frame sourceFrame,
    bool disposeOldView
)
Public Function SetView(
    view As View,
    updateControllers As Boolean,
    sourceFrame As Frame,
    disposeOldView As Boolean
) As Boolean

Parameters

Type Name Description
View view

A View object which is set for the current Frame.

Boolean updateControllers

true, if the Frame's Controllers are activated after setting a new View; otherwise, false.

Frame sourceFrame

A Frame object in which creating a new View was requested.

Boolean disposeOldView

true, if the Frame's old View should be disposed; otherwise, false.

Returns

Type Description
Boolean

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

This overload of the SetView method allows you to apply Application Model changes to a View without recreating it. Save the Frame's View to a variable, then set the Frame's View to null. Make the required changes to the model and then set the saved View back to the Frame.

View view = Frame.View;
if(Frame.SetView(null, true, null, false)) {
    // Make required changes with the model here.
    // ...
    view.LoadModel(false);
    Frame.SetView(view);
}

It is recommended to pass false to the View.LoadModel method to avoid creating controls within this method. Otherwise, the OnViewControlCreated methods of View's Controllers will not be called.

The complete example of a Controller that uses the SetView method is provided in the How to: Apply Application Model Changes to the Current View Immediately topic.

See Also