In M-V-VM where does my code go?

Posted by Nate Bross on Stack Overflow See other posts from Stack Overflow or by Nate Bross
Published on 2010-06-11T19:10:56Z Indexed on 2010/06/11 19:12 UTC
Read the original article Hit count: 240

So, this is a pretty basic question I hope.

I have a web service that I've added through Add Service Reference. It has some methods to get list and get detail of a perticular table in my database.

What I'm trying to do is setup a UI as follows:

  1. App Load
    1. Load service proxy
    2. Call the GetList(); method display the results in a ListBox control
  2. User Double Clicks item in ListBox, display a modal dialog with a "detail" view

I'm extremely new to using MVVM, so any help would be greatly appreciated.

Additional information:

// Service Interface (simplification):

interface IService 
{
    IEnumerable<MyObject> GetList();
    MyObject GetDetail(int id);
}

// Data object (simplification)
class MyObject
{
    public int ID { get; set; }
    public string Name { get; set; }
}

I'm thinking I should have something like this:

MainWindow
    MyObjectViewUserControl 
        Displays list
        Opens modal window on double click

Specific Questions:

  1. What would my ViewModel class look like?
  2. Where does the code to handle the double click go? Inside the UserControl?

Sorry for the long details, but I'm very new to the whole thing and I'm not educated enough to ask the right questions.

I checked out the MVVM Sample from wpf.codeplex.com and something isn't quite clicking for me yet, because it seems very confusing.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wpf