MVC architecture - Windows Forms

Asked

Viewed 598 times

0

How to implement the MVC standard using Windows Forms? I would like to understand better how to separate the Views, Controllers and Models following this development model.

  • A little bit of concept MVC. Maybe it’ll help.

1 answer

0


Windows Forms does not follow any MVC concept, but you can implement as you wish. Also, it makes no sense to want to use MVC in Winforms.

In contrast, Windows Forms is highly scalable. Views can be UserControls, and already the Controllers and Models can be proper classes, where you define your signatures with abstract classes or interfaces.

The . NET Framework has ASP.NET MVC, but is applied to the Web. Windows Forms and Web have distinct paradigms and therefore follow Patterns designs different from each other.

In Windows Forms, the Views is equivalent to System.Windows.Forms.Control, but you don’t work directly with them in practice. You work with the Form or the UserControl. Form is the Windows window (modal), Usercontrol is an inherited control directly from Control, that you can enter anywhere (just like any other control).

All components of Winforms' structure containers inherit the Control, then you can add one object inside the other with the panel1.Controls.Add(panel2).

Models and controllers can be classes without a certain global standard. It is only you that implement "Controller" will pull information from a Model and call your "View" (Usercontrol) with the information obtained from Model. At first, this does not exist in Windows Forms as something native.

As mentioned above, Windows Forms is not intended to use MVC. It doesn’t mean that it’s impossible to implement, but you would spend time and still not be able to look as well as you wanted.


Browser other questions tagged

You are not signed in. Login or sign up in order to post.