views:

150

answers:

2

Hello friends,

I'm currently writing viewmodels for my (WPF/C#) app.

I have to do a lot of copy and paste though. Isn't there a way to generate the viewmodel from the model like generating the model from the database?

I haven't found anything about it on the net ...

+2  A: 

Maybe have a look at automapper. This would at least save you from manually copying the properties between viewmodel and model.

M4N
I haven't checked automapper yet ... Does this work with C# Express?!
MAD9
+1  A: 

Have a look at Karl Shifflet's XAML Power Toys. It's a Visual Studio plugin which includes various helpers for developing WPF or Silverlight applications. One of the features is exactly what you're looking for:

  • Create ViewModel Class - from a VB.NET or C# code window, easily create a ViewModel stub that includes commands and exposed data class. Optionally you can elect to re-implement all Model properties on the ViewModel.
Thomas Levesque
too bad - it doesn't seem to work with Visual C# Express 2008 =(
MAD9