Region manager is empty

Topics: Prism v4 - WPF 4
Feb 26, 2013 at 9:19 AM
I have a strange problem, that i can't figure it out..
I am building a composite WPF application using prism. for that i am using UnityBootstrapper for using the UnityContainer, and using Region Manager that passed threw all modules to render the UI parts to the main shell.
everything is working good.

But, when i'm replacing all my WPF base controls to DEVExpress controls.
i notice that everytime the "region manager" instance is passed to each Module constructor, it comes empty..
I asked few people that told me build an adapter to every 3rd pary control, i did so, and still the region manager comes empty.

But what is more strange, that despite it seems that the region manager don't register nothing to the regions, All the views are injected correctly to the views in the shell..??!!
(the _regionManager remains empty even after i register view to it: _instance = _container.Resolve<InstanceBody>(); _regionManager.RegisterViewWithRegion("Body", () => _instance); )
Feb 26, 2013 at 6:57 PM

Several users in the past had reported incompatibility issues between Prism regions and DevExpress controls. In this case, I believe the problem could be related to the fact that some DevExpress controls do not inherit from WPF's FrameworkElement class:

Based on my understanding, after Prism creates a region it tries to register it in the corresponding RegionManager . To find it, Prism will try to "climb up" the visual tree until it finds an attached RegionManager object in a control (for example, the RegionManager attached to the shell window.) However, in order to do so, Prism requires that all the components in the visual tree inherit from FrameworkElement . If a non FrameworkElement is found in the visual tree, Prism is not able to keep "climbing up;" hence, it won't be able to find a RegionManager to register the region. As a result, the RegionManager does not contain the regions. As an example, this behavior is also happens when using DataTemplates as they do not inherit from FrameworkElement either.

As far as I know, the reason why the views are still being shown is that Prism is able to create the regions (which could mean that your RegionsAdapters are working correctly) and that any view registered in a region is added when the region is created, without requiring to use the RegionManager , so their are not affected by this issue.

As a possible workaround, I believe you could try using an approach described in the following blog post to work around this same behavior when using DataTemplates :
I hope you find this useful,

Damian Cherubini