1) Should I have the moduleManager as a parameter in my MenuModuleView's constructor?
Technically you could. Practically speaking though, if you do this you will still want to define a default constructor for your view. Otherwise, your view will not work in designers. Therefore, I recommend that properties be used to pass in dependencies to UI components.
2) How do I get the catalog accessible from inside MenuModuleView, in order to enumerate the available modules?
You would depend on Prism's IModuleEnumerator
interface and dependency injection will take care of supplying the module enumerator to your view. Assuming you're using Prism with the Unity container, that would look something like this:
[Dependency]
public IModuleEnumerator ModuleEnumerator
{
get; set;
}
3) From MenuModuleView, as I enumerate through the modules, I create the buttons, assigning the ModuleInfo to the button's Tag property. This way, I have only one click event to load the module. Is this correct? It smells a bit work-aroundish to me..
I would suggest you have each button raise the same WPF command and instead assign the ModuleInfo
to the Button
's CommandParameter
property. Again, Prism has infrastructure to help you do this cleanly in a composite scenario. See the DelegateCommand
class.
As a final note, be aware that whilst you may be able to lazily load your modules, you won't be able to unload them. For that, you will require AppDomain
isolation, which is a whole other kettle of fish.
HTH, Kent