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.开发者_Go百科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);
I see above you found the solution. However for additional issue if there is I am posting a related issue that I had and DevX supports solution link.
I had similar issue with DevExpress DXTabControl where upon navigating (from Prism module) it will not display the desired tab. DevExpress support recognized this is an issue. So they gave a solution in the following forum post.
Basically the behavior as well in the custom adapter needs to be overridden as well for certain devX controls. (for my case it was DXTabControl.
Here is the link, and follow the last pot by DevX support Alexander, and download his sample and he coded the custom adapter inside bootstrapper file, (you can put it in a separate class which it should be, I guess he just rushed to give a solution).
http://www.devexpress.com/Support/Center/p/Q360416.aspx
With document group, I have not tried, but I'll try to recreate your issue and see if same solution ( by overriding behavior in adapter) works there as well.
精彩评论