toumir
toumir

Reputation: 641

Prism + Wpf : Nested region not loaded by RegionManager

I have four(4) regions in my shell:

  1. RibbonViewRegion : To inject tabs

  2. RibbonTabRegion : To inject group of controls

  3. RibbonGroupRegion : To inject one control (button, combobox,...)

  4. ContentRegion : main content region

    <telerik:RadRibbonView prism:RegionManager.RegionName="{x:Static inf:RegionNames.RibbonViewRegion}" ApplicationName="Demo"> <telerik:RadRibbonTab Header="Principal" prism:RegionManager.RegionName="{x:Static inf:RegionNames.RibbonTabRegion}"> <telerik:RadRibbonGroup Header="Navigation" prism:RegionManager.RegionName="{x:Static inf:RegionNames.RibbonGroupRegion}"/> </telerik:RadRibbonTab> </telerik:RadRibbonView> <ContentControl Grid.Row="2" prism:RegionManager.RegionName="{x:Static inf:RegionNames.MainContentRegion}"/>

In module Initialize method, when i inject my view like this:

RegionManager.Regions[RegionNames.RibbonGroupRegion].Add(Container.Resolve<MyView>());

an exception occurs:

An exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in Prism.Wpf.dll but was not handled in user code Additional information: The region manager does not contain the RibbonGroupRegion region.

Effectively: when I set a break point at this line, I notice there is only three regions loaded - RibbonViewRegion, RibbonTabRegion and ContentRegion

my question is: why my RibbonGroupRegion is not loaded by RegionManager ?

note: i implemented the RadRibbonGroupRegionAdapter and it works fine.

guide me, thanks in advance.

Upvotes: 0

Views: 910

Answers (1)

toumir
toumir

Reputation: 641

I resolved it, I replaced this code :

RegionManager.Regions[RegionNames.RibbonGroupRegion].Add(Container.Resolve<MyView>());

by this :

RegionManager.RegisterViewWithRegion(RegionNames.RibbonGroupRegion, () => Container.Resolve<MyView>());

and it works

Upvotes: 1

Related Questions