Region not loaded by the RegionManger

2019-03-03 20:58发布

in a prism 6 based application, this is a part of my shell, and QuickAccessToolBar region defined like this:

<telerik:RadRibbonView>
        <telerik:RadRibbonView.QuickAccessToolBar>
            <telerik:QuickAccessToolBar prism:RegionManager.RegionName="{x:Static inf:RegionNames.QuickAccessToolBarRegion}"/>
        </telerik:RadRibbonView.QuickAccessToolBar>

The RegionManger will not be loads the region,

and when will replace the definition above(just for demo purposes) by this :

<telerik:RadRibbonView >
        <ContentControl prism:RegionManager.RegionName="{x:Static inf:RegionNames.QuickAccessToolBarRegion}"/>

The RegionManager loads the region!

my question is:
what's Wrong in my XAML ? my be the region was defined inside a complex property? Can you guide me, thanks in advance. best regards.

Solution :

Very good answer Brian, it works like a charm, as Brian said:

  1. first of all we name the targeted element:
<telerik:RadRibbonView.QuickAccessToolBar>
    <telerik:QuickAccessToolBar x:Name="QuickAccessToolBar"/>
</telerik:RadRibbonView.QuickAccessToolBar>
  1. in the code behind (the Shell in my case) :
public Shell(ShellViewModel viewModel, IRegionManager regionManager)
{ 
 InitializeComponent();
 DataContext = viewModel;
 RegionManager.SetRegionName(QuickAccessToolBar,RegionNames.QuickAccessToolBarRegion);
 RegionManager.SetRegionManager(QuickAccessToolBar, regionManager);
}

Where RegionNames.QuickAccessToolBarRegion ="QuickAccessToolBarRegion" and regionManager is the RegionManager resolved by unity container

Thank you very much Brian, good night :)

标签: Prism
1条回答
Lonely孤独者°
2楼-- · 2019-03-03 21:56

My guess is that the QuickAccessTolbar is not part of the visual tree, so the region manager can't find it. Since this is a Telerik control, I am not aware of how they architected their control. You might have to do this in code behind instead.

First set the region name, then set the RegionManager using the attached properties.

RegionManager.SetRegionName(quickToolbar, name);

RegionManager.SetRegionManager(quickToolbar, rm);

查看更多
登录 后发表回答