module list of <interface> & RegisterType in viewmodel?

Topics: Prism v2 - WPF 3.5
Mar 5, 2010 at 12:05 PM

Two questions in one post, about v2 WPF.

I want the user to select an import module from a listbox in a dialog before they can use the shell.

Now I can't figure out what is the way to go, to get the module list, and how to register a type in the viewmodel?

Can I get some guidance what is good design practice for this?

Mar 5, 2010 at 4:39 PM

Hi,

If I understand correctly your two questions are:

  1. Is is possible to list all available modules before loading the Shell and showing them in a dialog for the user to perform some action?
    The answer is yes. This thread should help you getting the list of modules names. The following threads should provide some guidance on how to show a dialog before the Shell is loaded: After that, you will probably load the selected module on demand based on the user’s choice.
  2. How to register a type in the Unity Container in my ViewModel class?
    To achieve this you must have an instance (probably constructor injected) of your application’s container in your VM class. This document provides more information about type registration. You can check how this is done in some of the Quickstarts or Reference Implementation as this is usually done to register views and view models mappings.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

 

Mar 5, 2010 at 9:13 PM

Thanks Damian. You understood me well and your answers are clear.

But I was doing MVVM with binding the VM in the XAML, that way no constructor injection is possible, right? Do I have to change the way I work or is there another option?

Jasper

Developer
Mar 9, 2010 at 2:28 PM

Hi Jasper,

In that case you can use the ServiceLocator to resolve the UnityContainer, or you could even resolve the type you need directly through the ServiceLocator, without using the UnityContainer itself. You can find more information about this specific usage in this thread.

I hope you find this answer helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi