Can you specify a view interface to load via XAML?

Jan 5, 2009 at 8:28 PM
Is it possible to specify a view interface in the XAML which would be automatically loaded into a region?  That is, the shell might say "in this region I know I want to have an IMyView loaded here", rather than just giving it a name and then having the module say "load me into a region named XYZ".
Jan 7, 2009 at 1:45 PM



If you are using the Prism v2 drops you could find useful the Pull-based Composition QuickStart (located at Quickstarts\Visual Composition\TopDown\TopDownUIComposition.sln in the latest Prism v2 drop). This quickstart uses RegisterViewWithRegion method from the RegionViewRegistry to register a view with a particular region name, so whenever a region is created, it queries the RegionViewRegistry to obtain the views associated to that name. Besides, the region subscribes to the registry, therefore when a new view is registered for that region, it will be notified and the view will be loaded in it.

This quickstart also uses RegionContext attached property in order to share some context with the view that gets added to the region.


For more information related to this check the Pull-based Composition QuickStart article in the Prism v2 documentation.


Please, let me know if this helps.


Mariano Converti
Jan 9, 2009 at 2:57 PM
Thanks.  I'll take a closer look at that.  From my first look at it, at least from the sample, it still required the module to know the name of the region it was to be loaded into.  I am looking for a way for the module not to need know the name of the region.  But I need to do some more playing around.

For example, say I want to display the same module twice in the same Shell.  Currently to do that, as far as I can tell, you have to fiddle with C# since otherwise you'd need to be able to give two different ContentControl's the same region name.  So what I was thinking is that if you could specify an view interface in the XAML for a ContentControl instead of a region name, that would be one way to solve the problem.