Links controller to its view. The framework takes care of setting this property for every controller instance. Thus, in full accordance to the Model-View-Presenter pattern, any controller may access its view (see the example in the bottom).

Namespace:  MVCSharp.Core
Assembly:  MVCSharp (in MVCSharp.dll)
Version: 0.8.5217.34148

Syntax

C#
IView View { get; set; }
Visual Basic (Declaration)
Property View As IView
Visual C++
property IView^ View {
	IView^ get ();
	void set (IView^ value);
}

Remarks

The setter method of the View property is often used to do the necessary view initialization:
CopyC#
class MyController : ControllerBase
{
    public override IView View
    {
        get { return base.View; }
        set
        {
            base.View = value;
            // Do view initialization
        }
    }
}

Examples

Here we access the view from the controller:
CopyC#
class MyController : ControllerBase
{
    public void DoSomething()
    {
        if ((View as IMyView).InputValue < 0)
            MessageBox.Show("The input value should be not negative.");
        else
            (View as IMyView).OutputValue = Math.Sqrt((View as IMyView).InputValue);
    }
}

See Also