Composite View in Prism

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

Hi,

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.

Thanks.

Indro

Developer
Jan 19, 2011 at 1: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
http://blogs.southworks.net/gmaliandi

Jan 19, 2011 at 4: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.

 

Thanks.

Indro