Question

i want to split my views project into sereveral modules. i wanna have a main project that willl have ref to all modules and this main project will generate the view from the modules.

my question is how can i bind all the styles from the application to the other modules?

will it automatically recognize them?

and how will the view model templates will be located? cause now they r in a resource dictionary that i merge in the app.xaml

where shpuld i put them (i want them to be in their module project), how can i load thos resources?

Was it helpful?

Solution

What you want is easily achieved if you use Prism: http://www.codeplex.com/CompositeWPF

There's plenty of samples to get you started there.

The only question you ask that isn't answered by Prism is the ResourceDictionaries, but there are several ways to get around that, but I think this is the best way: Composite WPF (Prism) module resource data templates

The first answer should get you there. You'll lose a little design time support in your modules, but everything should come together correctly at runtime this way.

OTHER TIPS

good question. As Anderson Imes said, you can use Composite WPF, but there is another simpler option that's recently available if you make use of the Managed Extensibility Framework (MEF). There is another question I asked about how to do exactly what you're talking about using MEF. Basically it uses the extensibility features of MEF to make the application resources extensible, and then your modules "extend" the application resources with their DataTemplates (Views). Then you just add your ViewModel to the GUI wherever you want, and WPF takes care of applying your View to it. I've been building an application on this model and it's working really well.

The benefit of using this method is that your app.xaml file doesn't have to "know" about all your View modules, and you're free to slice and dice your application any way you like (I prefer to segment it by feature, then by layer).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top