Controller / static state class in a WinForms application - where to put it?

I am writing a WinForms application and want to have a "MVC-Type" project. Actually it is more MVP or MVVM ,.

The plan is to have a central controller that does all the actual work, so that the forms simply display the ViewModels and handle the user input, but everything that actually does something goes through the controller.

I'm just wondering, this is a good idea, and where to put the controller? The current idea is to have a static class that is initialized in Program.cs (sending some dependencies like IMyDatabaseRepository), so that it just remains a controller that delegates work between the user interface and the model.

As you can guess, I come from a web background and do not have much experience with WinForms architecture. Previously, my MainForm was a Controller class containing all state variables, which obviously means that my MainForm is my application, and not just part of the user interface.

+3
source share
3 answers

Good question Michael!

Here are some links:

We hope that this will help you structure your project correctly!

+2
source

, , Structuremap, .
- , . StructureMap .
- WinForms, WPF, MVC WinForms.

0

You might look at the WAF Windows Forms Adapter . It comes with a sample BookLibrary application that uses the Controller / MVVM construct with Windows Forms.

0
source

Source: https://habr.com/ru/post/1717575/


All Articles