views:

58

answers:

1

Im writing a wpf project and using the MVVM paradigm, what i was wondering is if i should write my view model classes in their own project.

Advantages i can see is that your ui project would never have to know about your business logic. (not have a reference to it)

however if i want to use the ICommand interface in my view model i still need a reference to PresentationCore which may indicate that i should be in my ui project.

comments suggestions most appreciated.

A: 

I don't think there's an overwhelmingly compelling way to do it one way or the other. I tend to keep VMs and their views in the same assembly, but within a different folder structure. For example, I might have ViewModels/Foo/Bar/CustomerViewModel and Views/Foo/Bar/CustomerView.xaml.

I don't think there's a problem splitting out the views and view models either. Having the VM assembly reference view-related assemblies such as PresentationCore is only natural. After all, your view models are part of your view layer.

HTH, Kent

Kent Boogaart