MVVM (Model-View-ViewModel) Pattern For Windows Form Applications, using C#
The MVVM pattern is in favour of WPF/Silverlight developers because of its advantages. Microsoft says that MVVM:
MVVM is for WPF, but is there any way to have the advantages for WinForms too? The answer is yes (good news or maybe not so new). Windows Form Applications can also have the advantages, and of course it doesn't mean the exact real Model-View-ViewModel (MVVM) pattern. I searched and found many approaches (Google Search) some of them were great and some not(!) But I've tried to present a simple useful solution. I hope you'll be interested.
As you know, Program Logic and Content are separated In ASP.Net. And also in WPF, Program Logic is separated from UI. In Windows Forms, I preferred to use partial classes to separate Program Logic from UI until MVVM pattern has been introduced to me. I interested in using the pattern for WPF, so I decided to find a same way for WinForms too, but I was always too busy to work on it. One day, I tried to impose MVVM on WinForms, and here is the result of 3 spare hours working on the subject.
MVVM means Model-View-ViewModel:
1. View: It refers to the elements that displayed by the UI. As some people say, View is UI and some others say that View is UI "but" Logic (I like the second one). And also, it passes commands to ViewModel.
화면 UI 에서 보여줄 요소들을 참조하는데요. VIEW 는 그냥 화면 UI 로 보시면 되고, 또는 UI 이지만 나름 로직도 있다고 합니다. 이는 ViewModel 에 command 를 통해 전송됩니다.
2. ViewModel: It's an abstraction of the View, or mediation between View and Model. It passes Data between View and Model.
ViewModel : View 를 추상화 한것이라고 생각하시면 되며, 이는 View 와 Model 간의 중간 매체 입니다. View 와 Model 간의 데이터를 전송합니다.
3. Model: It represents data from DAL (Data Access Layer) or a Domain Model. So, Model is not DAL but refers to it.
Model : 이는 data access layer 즉 데이터를 처리하는 대표적인 곳입니다. 또한 Domain model 이라고도 하죠. Model 은 Data Access Layer 가 아닌 단지 이를 참조 한답니다.
msdn 메거진에 이론 설명이 자세히 나와 있습니다.
|Linked List 구현하기 (0)||2012.11.09|
|c# 으로 Yammer API 호출해 보기 (0)||2012.07.05|
|MVVM (Model-View-ViewModel) Pattern For Windows Form Applications, using C# (0)||2012.04.17|
|msdn 의 code 저장소 (0)||2012.03.27|
|엑셀 (excel) 을 sql 2005 이상 버전에 SqlBulkCopy 함수로 저장하기 (0)||2012.03.27|
|Delegates and Events in C# / .NET (1)||2012.01.30|