Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Deep Dive MVVM

58 minutes, 26 seconds


Right click “Save as…”

Slides (view online)

In 2010, the MIX session "Understanding the MVVM pattern" helped you to understand the basics of this very important pattern used in Silverlight, WPF and Windows Phone 7 applications. Building on this foundation, this year’s session will show you with a lot of code samples how to build complex interactive applications using proven best practices and powerful tools. Laurent Bugnion, a user and promoter of MVVM since the early days, author of “Silverlight 4 Unleashed” and of the acclaimed MVVM Light Toolkit, will help you to deep dive in MVVM and explore topics such as navigation, showing dialogs, collecting user feedback, handling multiple views and viewmodels, and more.

For more information, check out this course on Microsoft Virtual Academy:

Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • Dan FernandezDan


    Would be great if you can tell us your experinence on following subjects:

    1. reusable viewmodels on wp7/desktop - is this a dream or not?

    2. dealing with extended grid-like data view and editing scenarios - when you have little fields in model and lot of things to do on ui

    3. viewmodel lifecycle - what approach to choose and how/when?

    4. data syncronization between different viewmodels displaying same data (or data in VM1 related to another data in VM2) - is this viewmodel or model responsibility? what are best practices?

  • pippopippo

    where's the video?

  • Laurent Bugnionlbugnion Laurent Bugnion

    @pippo: I need to give the session first Wink The session is taking place on the 12th of April 2011. Videos are typically posted a couple of days after the event. Stay tuned!



  • Oscar AgredaOscar Agreda

    Laurent your MvvM is changing many developers life for the good.. Thank you.

    Cant wait to see your April 12, 2011 Session

    here is the John Papa, Kung Fu Implementation that he uses your toolkit, for example

    and , is so good that even Ward Bell from Idea Blade, improved on it

    very powerful Business Creations possible becasue of your work.


  • VitaliyVitaliy

    Hey Laurent,
    Could u pls elaborate on best practive to link Mockup data services (data for Blend) and Real Data services with ViewModel.
    And how all this can work together in Prism application.
    May be you have new ideas besides ModelViewLocator...

  • JediJedi

    Laurent, your last year videos turn the world upside up in me head.
    Thanks a lot!
    Your toolkit is amazing, and your examples are awesome.
    Waiting for video of that session!

  • ingamxingamx

    Hi Laurent,

    Thanks for being! I am waiting for the video. Any scenarios on combining mvvmlight with MEF?

  • Thank you Laurent!  Fantastic stuff!

    Channel9 team:
    The MP4 encoding is not compatible with iOS devices. (Tried iPhone, iPad, iPod) Error: "Some of the videos in your iTunes library, including the video ... were not copied to the ... because they cannot be played on this ..."

  • PomAH4uKPomAH4uK

    Nice presentation, thanks!

  • HelloWorldHelloWorld

    Very good presentation. I really appreciate your work on the MVVM Light toolkit. I have several comments:

    JSONDemo -
    I personally don't like the idea of forcing Friend to inherit ObservableObject. The friend class could already inherit something else already. It could also belong to some other project/library that I have no control. Also, they way FriendViewModel has Friend property kind of violate the Law of Demeter.
    In my opinion, I prefer having the FriendViewModel encapsulates all properties of Friend. That's what I did for my own projects.

    DialogService / DialogControl -
    I think you might like to know that there is a Popup control.(http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup(v=vs.95).aspx
    My IDialogService is actually a part of a utility library. There is a concrete implementation of IDialogService which uses a XAML control within the library. By using the Popup control, I don't have to add the DialogControl to every XAML page. I just inject IDialogService to my ViewModels and I'm set.

    Thanks again for the presentation!

  • robertdrobertd

    Picture from computer display is unclear even on High Quality WMV video.

  • robertdrobertd

    Font in Visual Studio is too small.

  • Robert KozakRobert Kozak


    Just watching your session. I disagree that you can have Visibility and Brush types in a ViewModel. You want to have your ViewModel as abstract as possible so that you can use them 100% on another platform. iOS and Android are very popular now and the concept of Visibility or Brush may or may not transfer over to another platform.

    You can use enums or bool or strings and use a IValueConverter to convert them for the View to use.

    I'm developing a library for iOS ( and will have it ported to Android) called MonoMobile.MVVM with the goal that your existing ViewModels and Models should just need a recompile. Its the Views that need to be rewritten since the UI is different on every platform.

  • I was at the session and remember having the same thought, why having a Visibility value in the VM instead of a bool combined with a converter?
    But I am sure Laurent wanted his demo to be concise on that side (and converter are not new and not directly related to MVVM), he had so much stuff to show!
    Awesome session by the way.

  • Hello, does the source code of the demo can be shared?

  • Laurent Bugnionlbugnion Laurent Bugnion

    Hey guys! Finally I am back in Switzerland, and can answer some comments here.

    First off, the source code is available at http://blog.galasoft.ch/archive/2011/04/13/deep-dive-mvvm-samples-mix11-deepdivemvvm.aspx

    Also, the MVVM Light code shown here is released as a preview at http://blog.galasoft.ch/archive/2011/04/14/mvvm-light-v4-preview-3-bl16-mix11-edition-mvvmlight.aspx

    There are great questions in here, and I will answer them all over the next couple of days.... but first I really need to sleep after that crazy trip Smiley Stay tuned.


  • Obiwan007Obiwan007

    Anyone used Prism for a bigger project? MVVM seems not to be enough as we have to modularize the application.
    As far as I have seen - getting up to speed with Prism is difficult. So much to learn...
    Unfortunately something like a region managment system (dockmanager) seems to be not so easy either.

  • Laurent Bugnionlbugnion Laurent Bugnion

    @Oscar Agreda: I am super happy you like it. I must admit, I have not had so much fun coding for years Smiley Love that job, love the technology.

  • Laurent Bugnionlbugnion Laurent Bugnion

    @Vitaliy: Hi, My preferred way of creating design time or test time data is to use a data service (for example IFriendsService in the video) and to inject different implementation depending on the scenario (design, test, runtime)). As you will see in the video, I use an IOC container to inject the service in the ViewModel. This is not compulsory, you can also create the VMs in the ViewModelLocator. This is a clean way to connect to your data.

  • Laurent Bugnionlbugnion Laurent Bugnion

    @Jedi: So happy to hear that. You guys give me such energy to continue this work. Thanks all.

  • Laurent Bugnionlbugnion Laurent Bugnion

    @ingamx: Hi and thanks! Smiley You should check MefedMVVM by Marlon Grech, he is using both MVVM (strongly inspired by MVVM Light) and MEF. I used MEF and MVVM Light in many projects, and I love it as a lightweight alternative to PRISM.

  • Laurent Bugnionlbugnion Laurent Bugnion

    @Tolga42:Thanks for the kind words and the feedback. I will ping the CH9 team too.

  • Laurent Bugnionlbugnion Laurent Bugnion

    @HelloWorld: Thanks so much for the feedback. I appreciate that not everyone likes the same implementations, and it is fine. Let me explain why I chose this aproach:

    - JSONDemo: I do realize that some people dislike it, and honestly it is fine if you prefer the alternative way you describe. I rather met people who prefer avoiding replicating the properties, but if that works for you, by all means, go for it. About the proxy, note that WCF created proxies do in fact implement INPC, so they follow the same kind of things I am showing here. Not saying it is better, just saying it is the same Wink

    Yes, if Friend inherits something, this does not work. In which case you can just implement INPC manually, which is not a huge deal.

    - DialogService / DialogControl

    Yes there is, however I wanted to show the example in WP7 where I saw a LOT of ugly MessageBoxes being used Wink The custom control I demoed is one that I happened to use on some production applications myself, I thought it was cool. The point was that the showing of the dialog is the responsibility of the view, and that you can make one yourself, or use a popup, or...

    My IDialogService, the IDialogControl and the PhonePageBase are also part of my WP7 library. The Custom Control is not, because I like to tweak it with colors and design, so I just have a project template for VS10 that has this control within. Here too, I just inject IDialogService, and voila.



  • Laurent Bugnionlbugnion Laurent Bugnion

    @robertd: It is a compromise between small resolution (the projector was 1280x720 which is already wider than the usual 1024x768), 120% font size in Studio but not wanting to go higher in size otherwise I would have to scroll horizontally too much (which I already did in a few places, and I hate that). It is hard to find a good compromise. Hope it didn't spoil the video completely for you Smiley

  • Laurent Bugnionlbugnion Laurent Bugnion

    @Robert Kozak: The reason why I do not like to use IValueConverter is that it is a performance killer in WP7 lists. The scrolling is already not very good there, so adding a converter between the property and the value will cause the scrolling to be even more jerky. On the other hand, if you do Silverlight 4 only, then using a BooleanToVisibilityConverter is a bit cleaner I agree.

    Both Glenn Block and I (who are pretty strict about the code) agree that adding Visibility and avoiding the converter is acceptable if it provides a better UX. But I totally agree that if it causes an issue when porting the code, then you should use something else. As usual in software engineering, the correct answer is "it depends" Wink

  • Laurent Bugnionlbugnion Laurent Bugnion

    @xjpepitceo: Check my comment a bit earlier about the source code, it is available indeed.

  • Hi Laurent, I really enjoyed the session while I was at MIX, thanks again for the talk, code samples, and MVVM Light! Speaking of MVVM Light, one thing I've been wondering about ever since attending your talk is which version of MVVM Light to use for new WP7 projects that will be submitted to the marketplace in a couple of months. I noticed that V4 is currently out as a Preview release, which you likened to a CTP, but I wasn't sure how much time it would take to get to the Production release. Basically, I'd like to use some of the cool new V4 features (e.g., your IoC container), but I'm afraid to do so if it means that I may run into some serious "Preview Release" bugs that cause us to have to delay the release of our WP7 app. Sorry for the vague nature of my question, but any guidance you can provide on which version of MVVM Light to use in the near-term would be greatly appreciated. Thanks!
  • andineupertandineupert

    does someone know a good way to develop a MVVM application for WPF and MonoDroid?
    There's this wonderful Toolkit from Laurent for WPF applications and Robert Kozaks MonoMobile.MVVM for MonoDroid (alpha-status i guess), but is there a possibility to have one Toolkit/Framework on both?


  • andineupertandineupert

    or is it possible to combine those two, maybe?

  • Hi Laurent, with MVVMLight was my start with Silverlight pretty fast and I was inspired by your talk on Mix last year, John Papa Kung Fu Silverlight and I was looking forward to this talk since announcement on your blog. And Its great, many thanks!!



  • AlvaroAlvaro

    Hi Laurent,

    I used MVVM Light in my first Silverlight project and I liked how it keeps things simple and clear. At the moment though, we're using Caliburn.Micro, which offers a higher level of astraction and integration at the expense of extra complexity.

    One idea that I just had to, ahem, "borrow" from them (*wink*) is their RaisePropertyChanged method, which takes an Expression rather than a string. I'm sure you'll appreciate how much slicker and maintanable it makes the code. So instead of this:

    public const string ClientUriIdPropertyName = "ClientUriId";

    You'd do this:

    RaisePropertyChanged(() => ClientUriId);

    For validations it's also nice. Instead of this:

    Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = ClientUriIdPropertyName });

    Now I do this:

    Validator.ValidateProperty(value, GetValidationContext((() => ClientUriId)));

    All I did was add this to my own ViewModel base class (derived from yours):

    protected string GetName<TProperty>(Expression<Func<TProperty>> property)
    var lambda = (LambdaExpression)property;

    MemberExpression memberExpression;
    if (lambda.Body is UnaryExpression)
    var unaryExpression = (UnaryExpression)lambda.Body;
    memberExpression = (MemberExpression)unaryExpression.Operand;
    memberExpression = (MemberExpression)lambda.Body;

    return memberExpression.Member.Name;

    protected void RaisePropertyChanged<TProperty>(Expression<Func<TProperty>> property)

    protected ValidationContext GetValidationContext<TProperty>(Expression<Func<TProperty>> property)
    return new ValidationContext(this, null, null) { MemberName = GetName(property) };

    I don't know how you feel about "borrowing" other people's ideas, but this is one I definitely feel is worth adding to your ViewModelBase class to end the ugliness of passing strings around. What are your thoughts?


  • Laurent Bugnionlbugnion Laurent Bugnion

    @Alvaro: Hi, and thanks for the message. This is in fact already available in MVVM Light V4 (this is still not a final release, but can be loaded from http://mvvmlight.codeplex.com/SourceControl/list/changesets and built with http://galasoft.ch/mvvm/building/

    Details at http://blog.galasoft.ch/archive/2011/02/08/mvvm-light-v4-preview-bl0014-release-notes.aspx

    About "borrowing", MVVM Light is a composite of ideas and sometimes even implementations gathered from the community, for the community. It's all good Smiley



  • Laurent Bugnionlbugnion Laurent Bugnion

    @Kostkac:Thanks so much!

  • Laurent Bugnionlbugnion Laurent Bugnion


    No problems for asking! I am not entirely sure when the final release of V4 will take place. In fact, seeing the very positive response for the new bits, it might very well happen earlier than I had initially planned. That means that some of the features I wanted to build in V4 could come later, in a V5. 

    However, before I do V4, i have a couple of bugs I need to take care of. I am not sure exactly when I can do that. Let's go on a whim here and say that i hope I can release V4 this summer (but standard disclaimers apply Wink



  • robertdrobertd

    I think that this video should be redone, i.e. computer display should take the whole screen. I don't know why computer display is so unclear in this video in comparison to videos from other MIX conferences.

  • robertdrobertd

    Microsoft.Expression.Interactions is missing from References folder,
    because of that "03 JsonDemo - WP7 DialogService" solution can't be compiled.

  • robertdrobertd

    Installing Windows Phone developer tools resolved this problem.

  • AndersAnders

    I really like your presentations and examples. Thanks a lot :-)

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.