Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

How to implements MVVM design pattern with Winforms

Hi, im working on a project and i want to improve code structure and performance by using MVVM (Model View ViewModel) design pattern but since two days of search i have found nothing about this subject for winforms (a complete tutorial).

I need to implement this design pattern with a master / details interface, that mean when you click an item in a listview (master) it display all his information inside controls (details).

Someone have a link that explain this concept or can give me an example ?
(Apr 24, 2019 06:47 AM)Fhack Wrote:  Hi, im working on a project and i want to improve code structure and performance by using MVVM (Model View ViewModel) design pattern but since two days of search i have found nothing about this subject for winforms (a complete tutorial).

I need to implement this design pattern with a master / details interface, that mean when you click an item in a listview (master) it display all his information inside controls (details).

Someone have a link that explain this concept or can give me an example ?

Winforms support data bindings so this is possible in winforms,but i recommend you WPF.Here are some examples https://www.codeproject.com/Articles/364...odel-Patte https://github.com/VirtualOverrider/WinF...M-example.

Here you can look this article on MVVM basics https://msdn.microsoft.com/en-us/magazine/dd419663.aspx and I hope you go to WPF instead of Winforms because in WPF will have much greater and easier control.All the best
buy me a coffee eth:0x88621A52aa5Eb3b6503628369687111810186c58
(Apr 24, 2019 07:18 AM)itcorp Wrote:  Winforms support data bindings so this is possible in winforms,but i recommend you WPF.Here are some examples https://www.codeproject.com/Articles/364...odel-Patte https://github.com/VirtualOverrider/WinF...M-example.

Here you can look this article on MVVM basics https://msdn.microsoft.com/en-us/magazine/dd419663.aspx and I hope you go to WPF instead of Winforms because in WPF will have much greater and easier control.All the best

Thank for your answer but i have already read all of this articles... I don't find any way in winforms to make databinding with master / details view  😵

I have no time to rebuild all of my project with WPF, i think i will use MVC pattern because i understand it well.
(Apr 24, 2019 07:32 AM)Fhack Wrote:  Thank for your answer but i have already read all of this articles... I don't find any way in winforms to make databinding with master / details view  😵

I have no time to rebuild all of my project with WPF, i think i will use MVC pattern because i understand it well.

Did you look at this https://github.com/VirtualOverrider/WinF...M-example. because this is what you want as far as I can see.
buy me a coffee eth:0x88621A52aa5Eb3b6503628369687111810186c58
Winforms does support databindings as mentioned above but it's not as flexible as WPF bindings.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Apr 24, 2019 04:21 PM)0xDEAD10CC Wrote:  Winforms does support databindings as mentioned above but it's not as flexible as WPF bindings.

I just tried to explain it to him,in wpf viewmodel does not have to know anything view and everything still works great because wpf allows loosely coupling of the view from the viewmodel via databinding in xaml.I also think mvvm to suit more for wpf because it leverages the strong binding capabilities.
buy me a coffee eth:0x88621A52aa5Eb3b6503628369687111810186c58


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by fisica638Feb 8, 2024 08:07 AM 8 560 Feb 8, 2024 08:07 AM
Last Post: fisica638
[C#] by SIM-587985Sep 23, 2022 08:23 AM 3 286 Sep 23, 2022 08:23 AM
Last Post: MavenGradle
[.NET] by SIM-3933056Apr 16, 2021 02:08 PM 29 1,217 Apr 16, 2021 02:08 PM
Last Post: centan