This project has moved and is read-only. For the latest updates, please go here.

Is it possible to create class library using MVVM Light

Aug 30, 2013 at 2:54 AM
Our product loads only dlls. So we create class libraries and integrate WPF stuff in it following MVVM pattern. Now if want to use MVVM light how do i need to integrate that.
Aug 30, 2013 at 11:20 AM
All our modules are stand-alone dll's (class libraries with usercontrols) loaded into a Prism shell and use MVVM Light's messenger to communicate. Each module has it's own viewmodellocator, the viewmodels inherit GalaSoft.MvvmLight.ViewModelBase, ICleanUP and our own framework interface and use RelayCommand and Messenger etc.

As long as your DLL's reference the MVVM Light libs you should be good to go (don't quite me on that though).
Sep 2, 2013 at 11:34 AM
Thanks tazzer,

Could you please share a sample module. That would be of great help.
Sep 2, 2013 at 11:45 AM
I can't as it's pre-production commercial system so I unfortunately share a module.

I'm happy to pass on snippets, assist where possible etc but I can't share the code as it's IP and would break my terms of employment contract.
Sep 2, 2013 at 12:00 PM

You can reference MVVM Light from a class library and use the Messenger, SimpleIoc or any other class contained in MVVM Light. You must pay attention to two things:

1) The version of MVVM Light referenced by the class library must also be referenced by the application. We see sometimes some version conflicts, this is .NET standard really.

2) The Messenger, SimpleIoc etc all have default (static) instances which means that you can use them as long as all the modules run in the same AppDomain. For instance, you can send a message using the Messenger from your class library to the main app, no problems, but only if the library is loaded in the same AppDomain as the main app. This is in general the case.

Hope this helps