Take the 2-minute tour ×

I am completely new to WPF, so I am spending time trawling the web for examples and tutorials on how things should be done. I have concluded the way forward is to try and use the MVVM pattern as guidance for my application structure. I am completely comfortably with the theory if not with my technical ability. I have one or two questions, and hope you can perhaps point me in the right direction on a few matters regarding application design.

  1. I wish to maintain a list of Customers. I have seen several examples of this. These involve loading a Customers repository containing a list of Customer object. A corresponding View and ViewModel for the Customers is created. As the user selects a Customer to edit, a View and ViewModel is created for the Customer object in the Customers collection. This keeps everything in sync when changes are made. My question is: My Customer Model is very complicated, it contains basic Customer information, name, address etc, but also attributes about the Customer, category lists, product profiles, target budgets etc. I want these to be available for edit in the Customer View, but don’t want the overhead of loading them into the Customers repository. I only want to load the extended Customer information when required, but have the Customer View updated with changes. What’s the best way to achieve this?

  2. My second question is: If I split the Customer information across several Tabs, should I have a separate View and ViewModel for each Tab, or have a single View. What’s the best practice?

  3. I think I will use Linq to SQL to handle the database processing. In a multiple user environment Customers may be add by several users at the same time. How do I reflect the new additions made by others users in my Customers repository? Do I have to reload it?

  4. Any suggestions on handling database concurrency issues. If another user edits or deletes a Customer I am currently editing, what should happen when I try and save? I am familiar with Datasets and ADO.net, and handling any concurrency errors arising when using a DataAdapter, is there a similar method with Linq to SQL?

I appreciate there are lot of vague questions here. But I would be grateful of any guidance offered.

Regards Tim

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I will tell you my opinion, but you will have to form you own opinion.

I don't like the samples very much, because they are a lot of work only for one entity (customers). I have lots of entities in my app, so I ended up with some code generation and using more inheritance.

The samples need some reality check. For example, in the Josh Smith MVVM sample, if you change a customer, the change are propagated to the list and other places, this is nice in the sample, but if you have a business app, you don't want to propagate the changes unless the user have pressed "Save" and all the business rules applied to the object.

I also don't buy in the pure MVVM, where for are forbidden to put anything in the code behind, and you have to code lots of lines only for a double-click, come on people, it's a simple double-click.

On you question:

  1. Implement a lazy load list (see Rob Connery post)
  2. IMO, a single view.
  3. You have to reload. Add a refresh button to list and let the user decide when to refresh.
  4. Pass
share|improve this answer
Eduardo, Many thanks for you opinion. I totally agree with your comments. Samples are very useful and I am extremely greatful to anyone who makes the time to submit them. I just wish I could find one that explains how to do things in a real world, complex application. I done want the code, just I pointer in the right direction. –  Tim Nov 6 '09 at 14:39
add comment

I open sourced a sample framework called SoapBox Core for doing WPF with MVVM (and also making it extensible with MEF). If you ignore the MEF part, there are a few good ideas on how to do what you're talking about. I would particularly take a look at how the Options Dialog works, because that deals with the problem Eduardo points out (how do you deal with editing something but only publishing the results to the rest of the application when the user commits the change). In this case it's using the user settings in .NET as the backing store, but it could be using anything you want, like entities.

share|improve this answer
Many Thanks, I will download now and check it out. Regards –  Tim Nov 9 '09 at 9:17
add comment

Your Answer


