I wrote a custom region adapter for a DevExpress ribbon.
public class dxDocumentGroupRegionAdapter : RegionAdapterBase<DocumentGroup>
{
private DocumentGroup _instance;
public dxDocumentGroupRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)
: base(regionBehaviorFactory)
{ }
protected override IRegion CreateRegion()
{
return new AllActiveRegion();
}
protected override void Adapt(IRegion region, DocumentGroup regionTarget)
{
_instance = regionTarget;
regionTarget.Items.Clear();
region.ActiveViews.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler((x, y)
=>
{
switch (y.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (object __panel in y.NewItems)
{
if (__panel is DocumentPanel)
_instance.Items.Add(__panel as DocumentPanel);
else
{
if (__panel is UIElement)
{
DocumentPanel panel = new DocumentPanel();
panel.Content = __panel;
_instance.Items.Add(panel);
}
}
}
break;
case NotifyCollectionChangedAction.Remove:
foreach (DocumentPanel __panel in y.NewItems)
{
_instance.Items.Remove(__panel);
}
break;
}
});
region.ActiveViews.ToList().ForEach( x => regionTarget.Items.Add(x as DocumentPanel));
}
In the xaml of my shell I registerd a region
<dxd:DocumentGroup cal:RegionManager.RegionName="RibbonTabRegion" [...]
In the code behind I´m importing an instance of RegionManager.On demand the bootstrapper is calling my region adapter, but there is no entry of the region in my RegionManager. I also tried
RegionManager.SetRegionManager(this, rManager)
But without success. Curiously enough
rManager.RegisterViewWithRegion("regionName", typeof(view))
works for me, but rManager.RequestNavigate does not.
Any idea?
EDIT
I found a way to solve this problem. I have to register my region manually:
IRegionAdapter regionAdapter = new Prism.dxDocumentGroupRegionAdapter(this.Container.GetExportedValue<IRegionBehaviorFactory>());
IRegion region = regionAdapter.Initialize(this.documentContainer, Types.ConstantValues.MainRibbonTabRegionName);
this.tRegionManager.Regions.Add(region);