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:
- App Load
- Load service proxy
- Call the
GetList();
method display the results in a ListBox control
- 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:
- What would my ViewModel class look like?
- 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