I’ve recently started working with the Prism framework for building composite WPF applications and I have to say I’m quite impressed with what Microsoft has done there.
Prism has made it very easy for us to partition our large-scale application into reusable modules which are very self-reliant and still integrate tightly into the whole of the application – both in the business logic and the GUI layers.
Since the application we’re working on is quite complex and will offer a wealth of functionality which will be continuously added over time we need our approach to designing the application architecture to reflect these requirements.
When reading about the navigation capabilities of the Prism framework I thought that we would definitely need to implement something similar in our application. I was quite glad to find that Microsoft had already created something so sophisticated which we could use.
The “Developer’s Guide to Prism” offers a chapter on navigation and there is a blog post written by Karl Shifflett which provides a deeper insight into navigation in the Prism 4 framework.
Unfortunately I discovered that the Prism Navigation framework does not support locally scoped regions.
What does that mean?
(If “region” doesn’t mean anything to you, it’s time to read Chapter 7: Composing the User Interface of the developer’s guide.)
Well, when using Prism’s RegionManager you have to make sure that there are no regions which bear the same name.
Now, if you create a View which has its own regions defined and you instantiate more than one instance of this View you will end up with more than one region with the same name.
Prism allows for this scenario by creating a local RegionManager when adding the View which contains regions to a (global) region.
Unfortunately the Prism Navigation framework does not yet support scoped regions.
I found a recent discussion on the Prism forum on Codeplex where someone recommended adapting the source code of Prism’s RegionNavigationContentLoader to the scenario of using scoped regions.
I have tried to do that but have failed so far to achieve a successful modification of Prism’s source.
Did anyone come across the same problem and have you found a solution? I’d love to hear any thoughts on the topic.