MVVM

TwitterFacebook
Get flash to fully experience Pearltrees

WPF and MVVM tutorial 01, Introduction.

With Microsoft WPF technology, a new pattern is born and is going to be called MVVM (Model View ViewModel). This pattern is an hybrid from the old MVC and the old MVP patterns. Why a new pattern for the presentation? First of all WPF technology is giving us a kind of technology that can completely change the approach to design and code the UI. With the VMMV we can completely design an agnostic UI that doesn’t know the Model we are going to pass to it. http://blog.raffaeu.com/archive/2009/06/03/wpf-and-vmmv-tutorial-01-introduction.aspx
http://blog.raffaeu.com/archive/2009/06/05/wpf-and-vmmv-tutorial-02-the-model.aspx In the first part of this tutorial we saw the MVVM model and how it works. In this part of our tutorial we will work directly with the Entity Model and LinqToSQL. I am using a database-first approach so in my opinion using LinqToSQL will be better then Entitiy Framework. I am going also to show you an easy way to build a custom Unit Of Work to manage the context status with Linq 2 SQL. The Visual Studio Project. First of all open a blank Visual Studio solution, I called it WPF.Tutorial.VMMV .

WPF and MVVM tutorial 02, The model.

http://blog.raffaeu.com/archive/2009/06/05/wpf-and-vmmv-tutorial-03-the-user-repository.aspx

WPF and MVVM tutorial 03, The user repository.

Before starting to view in depth our model, or to design the views, I want to complete the DAL layer. Now that we have our unit of work implementation and our data context we need to implement a couple of repositories. During the time I saw different repositories.

WPF and MVVM tutorial 04, The Commands.

http://blog.raffaeu.com/archive/2009/06/15/wpf-and-mvvm-tutorial-04-the-commands.aspx In the previous posts we saw the basic of our project, the model (domain entities) and a simple repository . Note: please note that the sample I wrote about an agnostic UnitOfWork is just to show you a simple pattern to handle L2S but it can be done better. The ViewModel. What is the view model?
As we saw in the previous posts, a view model should be an abstract implementation of what the view needs to show about the model. We should implement an observable collection of something, we should implement an INotifyPropertyChanged interface and we should have a collection of RelayCommands . An INavigator interface to implement the navigation of our application. In this case I am using the navigator pattern for composite WPF applications . Beware because this is my implementation for the navigation but it depends on how you design your app (multi-win, tab, MDI). The INavigator implementation.

WPF and MVVM tutorial 05, The basic ViewModel.

http://blog.raffaeu.com/archive/2009/06/16/wpf-and-mvvm-tutorial-05-the-basic-viewmodel.aspx

WPF and MVVM tutorial 06, start up form.

The View Model for the Startup form. In our project, let’s go to the ViewModel section and create a new class. This class will inherit from the basic View Model class like the code below: Then we need to create 2 commands that we will then associate to two buttons in our XAML form. http://blog.raffaeu.com/archive/2009/06/17/wpf-and-mvvm-tutorial-06-start-up-form.aspx
http://blog.raffaeu.com/archive/2009/07/03/wpf-and-mvvm-tutorial-07-the-list-search.aspx Ok, starting from this post we are going to do something really interesting. In this episode we need to create a simple List windows, but as you will see the logic will not be so different then a one-to-many form. So for some commands like Save or Delete we can also build a predicate action like CanSave? CanDelete? and encapsulating some validation logic inside.

WPF and MVVM tutorial 07, the List search.

Jason Dolinger on Model-View-ViewModel » Lab49 Blog

http://blog.lab49.com/archives/2650 A while back, Jason Dolinger, a consultant here at Lab49, gave us a presentation on design in WPF with the Model-View-ViewModel pattern and the Unity dependency injection framework. Jason started with an application that one would write in a “traditional” way, with button clicks handled by event-handlers in the code-behind that then updated other parts of the UI. Using WPF data-binding, Commands, and Unity, he transformed it, piece by piece, in a much more manageable, encapsulated, readable, and testable M-V-VM design. It was awesome. UPDATE: I thought I should mention that while Jason’s presentation is geared towards WPF, the patterns he describes are very applicable for Silverlight as well. There are a few things to take note of, though:
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Using MVVM with Menus in WPF

http://www.julmar.com/blog/mark/2009/04/21/UsingMVVMWithMenusInWPF.aspx

Menus and MVVM (2)

http://www.julmar.com/blog/mark/2009/04/29/MenusAndMVVM2.aspx Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
MVVM has been a trending topic lately. And why shouldn’t it be? People want to build great WPF/SL applications and want guidance on how to build them using the framework’s strengths.

MVVM for Tarded Folks Like Me

Model-View-ViewModel (MVVM) Explained

The purpose of this post is to provide an introduction to the Model-View-ViewModel (MVVM) pattern. While I've participated in lots of discussions online about MVVM , it occurred to me that beginners who are learning the pattern have very little to go on and a lot of conflicting resources to wade through in order to try to implement it in their own code. I am not trying to introduce dogma but wanted to pull together key concepts in a single post to make it easy and straightforward to understand the value of the pattern and how it can be implemented. MVVM is really far simpler than people make it out to be.
Check out this page in {0} translated from {1} translated from Original: Translated: Automatic translation powered by Microsoft® Translator Start translating Stop translating Close Close and show original page Select

MVVM Links\Info

Open File Dialog MVVM

The best thing to do here is use a service. A service is just a class that you access from a central repository of services, often an IOC container. The service then implements what you need like the OpenFileDialog.
What I generally do is create an interface for an application service that performs this function. In my examples I'll assume you are using something like the MVVM Toolkit or similar thing (so I can get a base ViewModel and a RelayCommand). Here's an example of an extremely simple interface for doing basic IO operations like OpenFileDialog and OpenFile. I'm showing them both here do you don't think I'm suggesting you create one interface with one method to get around this problem.

WPF OpenFileDialog with the MVVM pattern?