Region in adorner (Fluent Ribbon Backstage)

Topics: Prism v2 - WPF 4
Aug 6, 2010 at 11:37 AM
Edited Aug 6, 2010 at 11:38 AM
I'm using Fluent Ribbon (http://fluent.codeplex.com/) and want to place a Region in the Ribbon Backstage.

<fluent:RibbonWindow x:Class="Shell" ....>
<fluent:Ribbon ...>
<fluent:Ribbon.BackstageItems>
<fluent:Ribbon.BackstageTabItem ...>
<ContentControl cal:RegionManager:RegionName="MyRegionName" />
</fluent:Ribbon.BackstageTabItem>
</fluent:Ribbon.BackstageItems>
</fluent:Ribbon>
</fluent:RibbonWindow>

Unfortunately, this doesn't work. As far as I know the reason is the following: In the fluent ribbon, the backstage items are not in the same logical tree as the RibbonWindow - they are in an adorner. But the RegionManager is attached to the Shell/RibbonWindow and can only be found from the ContentControl by walking up the logical tree.

To solve this I think I would have to attach the region manager manually to a parent of the backstage items (this does not seem to be possible in fluent, as the backstage and backstageButton are private and the BackstageItems is not a DependencyProperty) or even to each BackstageTabItem (which kind of defeats the purpose of using CAL in the first place.)

Does anyone have a better idea?

Thanks!
Aug 16, 2010 at 10:34 AM
Could the region manager maybe somehow detect it's in an adorner and search in the adorned element's logical tree, too?
Oct 5, 2010 at 9:06 PM

Hi,

I am not aware how Fluent Ribbon works. But if you need to expose a UI control as a region, you could create a Region Adapter. For more information on this topic you could take a  look at the following documentation section on MSDN:

On the other hand, if BackstageItems derives from ItemsControl, it will be able to act as a region.

Hope this helps.

Fernando Antivero
http://blogs.southworks.net/fantivero

Oct 18, 2010 at 7:39 AM

Hi,

Let me clarify and simplify. Assume there's a third party control that presents some of my UI in a special adorner:

<UserControl x:Class="ThirdPartyControl" ...>
    <AdornerDecorator>
        <ContentPresenter /> 
    </AdornerDecorator>
</UserControl>

In that part of my UI I want to put a region:

<Window x:Class="MyMainWindow" ...>
    <ThirdPartyControl>
        <ItemsControl RegionManager:RegionName="MyRegion" />
    </ThirdPartyControl>
</Window>
  • Problem: The above attached property RegionManager:RegionName="MyRegion" will not work. (Assuming only MyMainWindow is registered with RegionManager.SetRegionManager( myMainWindowShell, regionMgr); )
  • Reason: The attached property event handler searches for regionMgr by walking up the logical tree. The adorner prevents this from working, Since the adorner content (the region) is not in the same logical tree as the container (myMainWindowShell).
  • My solution so far: Call RegionManager.SetRegionManager(uiElementInAdorner, regionMgr); where uiElementInAdorner is the ItemsControl in the adorner.
  • Downside of this solution: There are actually multiple regions in that adorner. Attaching the regionMgr to each region seems like a weak solution. A slight improvement would be to attach regionMgr to a common parent of all regions. (The parent would still have to be inside the adorner for this to work.) The ThirdPartyControl does currently not expose or allow for such a parent, so this is nont possible however.

 

  • My preferred solution: The Prism regions library is changed to work natively with adorners. (Not sure if this is feasible or realistic.)

 

  • Regarding your proposal of a Region Adapter: I'm not sure how that would help. My UI control that should become a region already has a working region adapter. I don't think it would make sense or help to write a region adapter for the ThirdPartyControl.

Cheers.

Oct 18, 2010 at 4:55 PM
Edited Oct 18, 2010 at 5:05 PM

Hi,

Thanks for reporting that. I will copy this as a work-item, so the product team will be notified. Additionally, the community can vote this.

I am glad that you found a possible workaround. I think that you can find interesting the following link, since a user has a similar scenario: Propogating inherited DPs to the adorner layer

If you have a repro sample of this without the third-party control, could you please send it?

Fernando Antivero
http://blogs.southworks.net/fantivero

 

 

Oct 18, 2010 at 5:06 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 19, 2010 at 7:23 AM

Hi

Thanks. I will look into the linked discussion and if time permits try to create a repro sample.

Cheers.

Oct 19, 2010 at 9:09 AM

Added a repro sample to the work item.

Mar 27, 2012 at 8:49 AM

You can inherit from the third party control.

In the static cto'r override the Backstage metadata with a property changed callback handler that adds the Backstage from the NewValue property of the event args, to the control's logical children.
In the public cto'r register to loaded event in which you can remove the Backstage from the logical children.
Override the LogicalChildren property so that get returns the control's Items and Backstage properties.