Composite View in Prism

Topics: Prism v4 - WPF 4
Jan 19, 2011 at 9:52 AM


I have two views, I am trying to compose a third view combining these two views and map that third view to my Region.

View 1 + View 2 => View 3 {maps:}  Region A.

This composition occurs statically, i.e. I need to create a View 3.XAML and put my views there. Is there any approach to dynamically compose a view?

Any pointers/snippets/links/resources are highly appreciated.



Jan 19, 2011 at 2:26 PM

Hi Indro,

Views can also hold regions, so you could have your View 3 define a region, and add View 1 and View 3 to that region. Then, you could add View 3 to Region A, which will result in the composite view (containing both View 1 and View 2) being added to the aforementioned region.

In case you want to add more than one instance of View 3, you should use scoped regions, since there can't be more than one region with the same name inside the same region manager. You might find the following chapter from the Prism MSDN documentation useful to this purpose. In the chapter, there are also explanations on the different approaches for UI Composition. If your composition should be static, you could benefit from the View Discovery approach.

I hope you find this helpful.

Guido Leandro Maliandi

Jan 19, 2011 at 5:25 PM

Hi Guido,

Thanks for your reply.

I will try this tomorrow for a small sample app using MEF.

Hope to bring some positive points though.