I’ve recently started working on a Win Forms application which needs some improving and restructuring. There are chances that a WPF version of the application is done in the future and I’m considering restructuring the Win Forms app to the MVVM pattern. The purpose is that when the time comes to develop the WPF I would only have to focus on creating WPF views and reuse the code from the previous version.
I’ve looked at a few posts on developing a Win forms application using the MVVP pattern and it does seem possible to develop Win Forms application using the pattern.
I’d like to know if the approach is advisable and if restructuring an existing Win Forms application to a MVVM pattern would ease the work load when developing a WPF version.
I’ve recently started working on a Win Forms application which needs some improving and
Share
This is not a good idea in my mind. Because a really big part why MVVM is so good in WPF, is the WPF bindings infrastucture.
WinForms doesn’t have such abilities, binding support is way lower. That is why WinForms use MVP pattern, where Presenter is responsible for providing data to the view.
You can try writing purely MVVM models, but then you’ll have to write quite a lot of ugly code inside your views in order to bind to the models and update them.
I would suggest stick to MVP, as this is quite a good aproach for WinForms, it creates well structured components, and then it is easy to recreate the same functionality in WPF and MVVM.