Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Scoped RegionViewRegistry?

$
0
0
I have a case where I'm displaying modal windows. These windows each have their own child container (unity CreateChildContainer()) and sub region manager (CreateRegionManager()).

As I understand it, when using scoped regions it is generally necessary to inject views into the appropriate regions.

It seems that PRISM is very close to being able to support discovery in this situation if only there were the concept of scoped RegionViewRegistry. As it is, when a sub region manager is created, it's method RegisterViewWithRegion() still uses the main registry.

I would like the ability to do something like the following each time a modal window is shown:
// Registry dependencies that ViewType may have
childContainer.RegisterType<IA,A>(new ContainerControlledLifetimeManager());
childContainer.RegisterType<IB,B>(new ContainerControlledLifetimeManager());

// Register view with region using delegate that builds view on the child container
subRegionManager.RegisterViewWithRegion("RegionName", 
    () => childContainer.Resolve(ViewType));
As it is, RegisterViewWithRegion seems to persist the delegate that was registered causing havoc the second time a modal window is shown and this code is repeated.

Are there any patterns for getting around this problem aside from directly injecting the view into the region?

Thanks.

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>