Real World WPF application with Simple MVVM

May 16, 2011 at 6:40 PM

Hello Tony,

Can you refer to a real world WPF application using Simple MVVM? We are starting a WPF in VSTO project using .NET 4.0 using MVVM pattern and I am wondering whether Simple MVVM will fit all our needs. I like the simpler structure in Simple MVVM than MVVM Light. But, I just want to make sure if there is no road blocks down the road.

Thanks,
Dinesh

Coordinator
May 16, 2011 at 8:07 PM

@Dinesh: Great question.  Yes, Simple MVVM Toolkit offers pretty much the same functionality for both WPF and Silverlight applications.  In this case you would use standard WCF instead of WCF RIA Services, which does not offer the same functionality for WPF as it does for Silverlight.  But that only applies if you are building n-tier applications.  If that is the case, you should take a look at the "Main" sample app, Parts 1 and 2, which are in the samples zip file installed with the toolkit.

Cheers,

Tony

May 16, 2011 at 9:06 PM

Thank you for your immediate response.

Dinesh

May 23, 2011 at 3:31 PM

Hi Tony

Just wondering about your recommendation to use WCF with WPF. Wouldn't it be best to use Entity Framework for a new project rather than WCF?

Cheers - Graham

Coordinator
May 23, 2011 at 4:27 PM

@Graham: Entity Framework is a data access technology that provides object-relational mapping.  WCF is used to support communication between client and services.  Typically, a service will use a data access API such as Entity Framework to handle data retrieval and persistence.  So my recommendation is to use the two together.  This is exactly how the SimpleMvvmRiaServices Visual Studio project template works.  If you watch the Real-World Mvvm screencast you'll see how Entity Framework is used by a WCF service: http://blog.tonysneed.com/2011/04/28/screencast-real-world-mvvm-with-wcf-ria-services.  There is also a sample included with the Toolkit that includes a more basic WCF service that uses Entity Framework: Main sample, Part 1.

Cheers,

Tony

May 23, 2011 at 4:46 PM

Hi Tony

Thanks for the quick response! I've watched the two screencasts and using RIA Services on top of EF in Silverlight makes perfect sense, and that's how I'm planning to architect my SL apps. I'm also keen to use the toolkit with WPF though, and was planning for small scale applications to just just code directly against EF. In fact, I have built a WPF version of your SL Northwind example against EF and it's working very well apart from a problem when editing a single entity. I was going to post this to the Issues area (tomorrow now - getting late in the UK) but I'll hold off in case you tell me I'm barking up the wrong tree :).

Cheers - Graham

Coordinator
May 23, 2011 at 5:24 PM

WPF using EF in a client / server scenario is fine for getting up to speed, and the Simple MVVM Toolkit will work well in this scenario. Entity classes generated by EF support two-way data binding by firing a PropertyChanged event in each property setter.  Eventually you'll want to encapsulate your EF code in a data access layer that is called from a WCF Service.  The Main sample (Parts 1 and 2) applies equally to both Silverlight and WPF and shows you how to do this.  If you describe your editing issue, I'll be happy to respond. Tony

May 24, 2011 at 11:57 AM

Thanks Tony - I'll post my problem in the issue tracker.