WPF/MVVM - keep ViewModels in application component or separate?

Posted by Anders Juul on Stack Overflow See other posts from Stack Overflow or by Anders Juul
Published on 2011-01-15T08:39:56Z Indexed on 2011/01/15 8:53 UTC
Read the original article Hit count: 253

Filed under:
|
|

Hi all,

I have a WPF application where I'm using the MVVM pattern.

I get the VM activated for actions that require user input and thus need to activate views from the VM.

I've started out separating the VMs into a separate component/assembly, partly because I see them as the unit testable part, partly because views should rely on VM, not the other way round. But when I then need to bring up a window, the window is not known by the VM.

All introductions I find place the VM in the WPF/App component, thus eliminating the problem.

This article recommends keeping them in separate layers : http://waf.codeplex.com/wikipage?title=Architecture%20-%20Get%20The%20Big%20Picture&referringTitle=Home

As I see it, I have the following choices

  1. Move VMs to the WPF/App assembly to allow VMs to access the windows directly.

  2. Place interfaces of views in VM-assembly, implement views in WPF/App assembly and register the connection through IOC or alternative ways.

  3. File a 'request' from the VM into some mechanism/bus that routes the request (but which mechanism!? E.g something in Prism?!)

What's the recommendation?

Thanks for any comments,

Anders, Denmark

© Stack Overflow or respective owner

Related posts about wpf

Related posts about mvvm