Design time support for Prism 4

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
Jan 4, 2011 at 7:26 AM

Hi Guys,


I've implemented design time support for Prism 4:

But I had to remove the "if (!IsInDesignMode(element))" statement from the RegionManager.OnSetRegionNameCallback callback method.

In my case I created an adapter to the RegionManager instead of changing the source code.

Is there any other way I could get rid of this statement without changing the code?

Jan 4, 2011 at 3:26 PM
Edited Jan 4, 2011 at 3:27 PM

Hi Tomer,

Thank you for sharing your findings on blendability for Prism. Another possibility for addressing your issue with the creation of regions in design time with the Region Manager would be to create an alternative Region Manager (a class that inherits from IRegionManger) that could be similar to the regular Region Manager implementation, but with a different OnSetRegionNameCallback method. Then, you could make your Design Time bootstrapper set your implementation of IRegionManager to the shell. That way, you would have the regular region manager in run time, and the one you've modified in design time.

The notes on the MefRegionManager class could be helpful to that purpose:

"Exports the RegionManager using the Managed Extensibility Framework (MEF).

This allows the MefBootstrapper to provide this class as a default implementation.
If another implementation is found, this export will not be used."

Also, it could be helpful to know that the Run method on the MefBootstrapper class obtains the Region Manager from the container and sets it to the shell:



RegionManager.SetRegionManager(this.Shell, this.Container.GetExportedValue<IRegionManager>());



I hope you find this helpful.

Guido Leandro Maliandi

Jan 4, 2011 at 3:44 PM

Thanks Guido for your quick and informative answer.

What I've done so far is something very simple.

I've created a simple class called "RegionManager" which has the relevant-for-XAML attached properties as in the original RegionManager.

Now when calling at design time, it uses its own OnSetRegionNameCallback method.

At runtime it just calls the original RegionManager attached properties. No need to implement the whole IRegionManager.

A great thing will be to have my solution for Prism Blendability in the next Prism drop/update.




Jan 4, 2011 at 4:23 PM

Hi Tomer,

Your approach seems valid as well. However, it might be helpful to name the class differently, so as to avoid confusions with the regular Region Manager; having a class named Region Manager, but which doesn't inherit from IRegionManager could be misleading.

On a different note, you could create a work item in the Issue Tracker so that the product team is aware of this for future releases. I've also added a link to your blog post to the Prism Knowledge Base so that other users can benefit from your approach.

Thank you for your contribution.

Guido Leandro Maliandi


Jan 4, 2011 at 6:55 PM

Sounds right what you're offering. I'll change it to something else.

Thinking of something like:

<ContentControl ts:Region.Name="regionName"  prism:RegionManager.RegionContext="context" ... />