I think that I have found one of the best articles on MVVM that I have ever read:
This article sums up what is in MVVM and what is outside of MVVM. Note, when I and most other people say MVVM, they really mean MVVM, Commanding, Dependency Injection + any other Patterns you need to create your application.
In WPF a lot of use is made of the Decorator and Behaviour pattern as well. The goal of all of this is to have pure separation of concerns. This is what every code behind file of every Control / Window / Page should look like if you are engineering your WPF and Silverlight correctly:
1 public partial class IdealView : UserControl
2 {
3 public IdealView()
4 {
5 InitializeComponent();
6 }
7 }
Figure: This is the ideal code behind for a Control / Window / Page when using MVVM.
1 public partial class IdealView : UserControl
2 {
3 public IdealView()
4 {
5 InitializeComponent();
6
7 this.DataContext = new IdealViewModel();
8 }
9 }
Figure: This is a compromise, but the best you can do without Dependency Injection
1Partial Public Class ServerExplorerConnectView
2
3End Class
Figure: This is the ideal code behind for a Control / Window / Page when using MVVM.
1Partial Public Class ServerExplorerConnectView
2
3 Private Sub ServerExplorerConnectView_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
4 Me.DataContext = New ServerExplorerConnectViewModel
5 End Sub
6
7End Class
Figure: This is a compromise, but the best you can do without Dependency Injection
Technorati Tags: .NET WPF Silverlight MVVM
No related videos found.
If you've made it this far, it's worth connecting with our principal consultant and coach, Martin Hinshelwood, for a 30-minute 'ask me anything' call.
We partner with businesses across diverse industries, including finance, insurance, healthcare, pharmaceuticals, technology, engineering, transportation, hospitality, entertainment, legal, government, and military sectors.
Hubtel Ghana
Epic Games
Philips
CR2
Brandes Investment Partners L.P.
Lockheed Martin
Flowmaster (a Mentor Graphics Company)
Sage
Milliman
Boeing
Xceptor - Process and Data Automation
Bistech
Boxit Document Solutions
Healthgrades
Ericson
Lean SA
DFDS
YearUp.org
Department of Work and Pensions (UK)
Washington Department of Enterprise Services
New Hampshire Supreme Court
Ghana Police Service
Royal Air Force
Washington Department of Transport
YearUp.org
Sage
Jack Links
Akaditi
Cognizant Microsoft Business Group (MBG)
Kongsberg Maritime