34 responses

  1. Nick Dowling
    August 5, 2013

    Small grammar correction – ‘loses site of the fact’ should be ‘loses *sight* of the fact’ and ‘any time of information in virtually any format’ should be ‘any *type* of information in virtually any format’ (I think)

  2. Server Automator
    December 15, 2012

    “you don’t work harder, you work less, and in exchange for doing less, your code is easier to write, to read, to maintain and to test” IS BS! You WILL always write more code using MVVM rather than using code behind. YOu WILL be working harder (because you write more code). It is NOT easier to read. Debatable if more code is ever simpler to maintain. Testing is simpler because the VM tier is unit testable which has always been a challenge for WinForms & WPF with code behind.

    For a button using code behind: OnClick(TheMethodName). Done. Right click it, go to code, and BAM you are in the event that gets raised. Going to do that with MVVM? NO WAY! Impossible. It’s a handful of extra code, you can not go directly to the event.

    Want a dialog window? Using(formobject form=new formobject()){form.showdialog();} and it disposes itself automatically. MVVM equivalent? There is NONE unless you write a form controller and all of the code necessary to manage a dialog window (any sizing, title bar, moving events etc etc etc…good luck under 150 lines of code).

    MVVM is great, and I use it with WPF all the time. But it’s not simpler. It’s not faster to write. And, it is not easier to read.

  3. Tevin
    October 14, 2011

    Thanks very much, Help a lot ; )

  4. Water Damage Restoration
    August 13, 2011

    Dim custID As Guid = (CType(V2_CustomerDataGrid.SelectedItem, _

    Dim loadOp = context.Load(context.GetCustDetailByIDQuery(custID))

    ‘CustomerDataForm1.ItemsSource = loadOp.Entities
    Dim taskList As ObservableCollection(Of v2_Customer) = New ObservableCollection(Of v2_Customer)
    ” Dim custID As Guid = (CType(V2_CustomerDataGrid.SelectedItem, _
    ” v2_Customer)).Cust_UUID
    ” Generate some task data and add it to the task list.
    For index = 0 To taskList.Count – 1
    taskList.Add(New v2_Customer() With _
    {.Cust_UUID = custID, .Billing_Zip = .Billing_Zip

    Dim taskListView As New PagedCollectionView(taskList)
    Me.CustomerDataForm1.ItemsSource = taskListView

  5. jeanine
    July 18, 2011

    Great post with simple approach to raising data events. Just what I needed. For VS2010 and Silverlight 4, the Expression.samples.interactivity needs to be changed to Microsoft.Expression.Interactivity.Core and include that reference as well. The CallDataMethod uh method has been changed to CallmethodAction. so changes — si:CallMethodAction MethodName=”TrimestersClicked”

    The MSDN for this is here –> http://msdn.microsoft.com/en-us/library/microsoft.expression.interactivity.core.callmethodaction_members(v=expression.40).aspx

  6. Paul
    December 15, 2010

    It cut off my code. take 2:

    <i:EventTrigger EventName=”SelectionChanged”>
    <si:CallDataMethod Method=”HandleSelectionChanged” />

  7. Paul
    December 15, 2010

    I downloaded Jason Quin’s code and made the following change to PeopleView.xaml and got it to work:

  8. Rod
    September 27, 2010

    @Jason Quinn: Ok, I downloaded your version and it now builds (using VS010 pro) but the selection changed event does nothing?

    In this original example it calls the method HandleSelectionChanged on the VM, but on yours it calls “ViewModelMethod” which does nothing. I tried changing this to the method “HandleSelectionChanged” but it still does not fire.

    Has anyone got a working version of this in 2010? thanks

  9. Rod
    September 27, 2010

    I could not get the source to build (using SL4 and VS2010) –

    Error 1 The tag ‘CallDataMethod’ does not exist in XML namespace ‘clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity’

    Error 2 A value of type ‘CallDataMethod’ cannot be added to a collection or dictionary of type ‘TriggerActionCollection’.

    But when I browse with the Object Browser it is there?

  10. Richard Ebel
    August 4, 2010

    Richard Ebel :It works with VS EX 2010 and Silverlight 4 and the following changed PeopleView:

  11. Richard Ebel
    August 4, 2010

    It works with VS EX 2010 and Silverlight 4 and the following changed PeopleView:

  12. Jason Quinn
    June 15, 2010

    I’ve fixed the code sample so it works now with visual studio 2010 and Expression Blend 4. It can be found at http://cid-136dba83ff6950a3.office.live.com/browse.aspx/Public/Code%20Samples

    • jeanine
      July 18, 2011

      Can you give me more here? You have 4 projects there and none are really labled. Or just give the information. Thanks!

  13. Jesse Liberty
    May 25, 2010

    @Per H
    Thanks for taking the time to post this after working it out. Your comment was cut off, if you get a chance to fill in the details, that will be terrific.

  14. mark
    May 22, 2010

    Download code doesn’t build. It’s a well written article code. Thanks for the effort. I’ll see if I can get it to compile.

  15. Bryon
    May 21, 2010

    @Per H , where are these libraries found? I’m using VS 2010 and Expression Blend 4.

  16. DelC
    May 19, 2010

    @Jesse Liberty

    That would be Kool ;-) I’ll try and see if I can get something done in the next week. If I don’t then I’ll fess up to being lazy and leave it for you to take it on. Cheers.

  17. DelC
    May 13, 2010

    Hi Jesse,

    Good post, particularly on how simply you can use the Blend Samples to extend the commanding.

    I know you weren’t trying to write the definitive guide to MVVM but it would be good to have a little more on the View Model/Model relationship as mocking up the data within the VM avoids that somewhat.

    We’ve been on the MVVM kool aid since last year and it’s definitely the way to go, although sometimes I think the MVVM police might be about to storm in.

    Some of the team got to see you on your UK visit – thanks again for that.

    • Jesse Liberty
      May 16, 2010

      I agree, and if you would like to write something and have me chime in and send it back and once done publish here with joint authorship, that would be a gas. If not, it is definitely on my follow-up list. :-)

  18. Jesse Liberty
    May 10, 2010


    @Jeff Ballard

    Jeff Ballard :

    Am I correct in stating that the part with the codeplex expression samples and interactivity is basically a way to implement commanding for non button and hyperlink base controls in MVVM?

  19. Jesse Liberty
    May 10, 2010

    @Ken Byrd
    The problem is that I didn’t explain what I wanted to do, and so you are totally right wrt what i wrote, but not what i meant

    What I was trying to show was an example where a change in the state causes you to want to invoke a method (not just update the view).

  20. Luciano Evaristo Guerche (Gor
    May 10, 2010


    Are you breaking any MVVM rule when calling System.Windows.MessageBox.Show in the ViewModel?


    • Jesse Liberty
      May 10, 2010

      Yes, calling messagebox.show from the vm would be a temporary hack until you move the ui to the view.

  21. Ken Byrd
    May 10, 2010

    Why would this method be preferable to simply implementing a SelectedPerson property on the ViewModel?

    {ListBox ItemsSource=”{Binding People}”
    SelectedItem=”{Binding SelectedPerson, Mode=TwoWay}” />

    Within your ViewModel, you could simply watch for changes to the SelectedPerson property which wouldn’t require 3rd party codeplex code!

  22. Per H
    May 9, 2010

    Hi. This is a great example, and I agree that one has to apply a little KISS to MVVM in order to get your brain around it! However, using VS2010RTM and Blend4 beta, I think the following needs to be changed?

    1) I updated the references and the XAML:


    2) and changed the CallDataMethod to CallMethodAction like this:

    • jeanine
      July 18, 2011

      How was the calldatamethod changed? thnx.

  23. JasonBSteele
    May 9, 2010

    And I thought references to drinking Kool Aid were more to do with Kool Aid Acid Test… which is more to do with seeing things that aren’t there! ;)

  24. zire
    May 9, 2010

    Heh ;) Hi Jesse I like it very much your intro in this post . Trend’s killing our precious time.

  25. Jeff Ballard
    May 8, 2010


    Am I correct in stating that the part with the codeplex expression samples and interactivity is basically a way to implement commanding for non button and hyperlink base controls in MVVM? I was trying to do something similar using Prism and was having trouble getting it to work although I did have only a few minutes to troueshoot before I had to leave for a family event. :)

    Great article!

Leave a Reply




Back to top
mobile desktop