wpf - PRISM + MEF + MVVM -- Not sure where to really start? -
what i'm using:
- visual studio 2010
- microsoft .net framework 4
- prism v4
what trying figure out how started prism + mef while maintaining mvvm pattern. when go prism quickstarts, has prism + mef, comments in project state quickstart example not implement mvvm. i'm not sure mix/match shell follows mvvm (and regions).
basically, want use mef able load assemblies (modules) @ run-time. and, want setup regions in shell , have shell use mvvm (so can databind things shell). every example online either prism, prism + mvvm, prism + unity, silverlight examples, prism + mef, etc. can not find wpf prism + mef + mvvm examples or information. have no idea how setup bootstrapping , such going.
once part done, i'm sure i'll figure out how load other controls using mvvm shell. great, resources deal directly situation apposed similar (i.e. prism + unity , without mef). thanks!
i have never used prism+mef myself, in question mention want able load modules @ runtime (with mef). don't need have mef for, because prism quite @ doing itself. setup pretty simple:
first, create prism module implementing modularity.imodule
. requires 1 method: initialize()
. here can setup needed module. extend constructor inject other interfaces might need (using unity).
then, create modulecatalog specify details of module created:
<modularity:modulecatalog xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:modularity="clr-namespace:microsoft.practices.prism.modularity;assembly=microsoft.practices.prism.composition"> <modularity:moduleinfo ref="your.moduleproject.dll" moduletype="your.moduleproject.module, your.moduleproject" modulename="module1" initializationmode="ondemand" /> </modularity>
the initializationmode
want set if need runtime loading. catalog can loaded in prim bootstrapper:
catalog = microsoft.practices.prism.modularity.modulecatalog.createfromxaml(new uri("modules.xaml", urikind.relativeorabsolute));
then need load module, reference imodulemanager
(dependency injection, yay!) , load module:
if (loadmodule1) var mymodule = modulemanager.loadmodule("module1");
now module known prism. keep in mind unloading not supported prism.
Comments
Post a Comment