Dynamically Load RibbonTab content at runtime

Ribbon for WPF Forum

Posted 13 years ago by Scott Huiskens
Version: 10.2.0533
Avatar
We have derived a ribbon control and added a new dependency property to it called TabsSources, which is a collection of view models that would be used to back a series of views, with each view corresponding to a tab in the ribbon control.

This works to actually create a correctly labeled tab within the ribbon control, but we've been unsuccessful thus far in populating the actual tabs with any content. Is there a best practice for populating ribbon tabs at runtime? The DP creates a new Tab and sets the Tab's DataContext to the ViewModel, but how would we write the xaml for the content to put in the corresponding View?

We've tried just using <ribbon:Tab...> in the view file but that did not work, and then we tried wrapping that in a <UserControl> but no luck there either.

Any thoughts/ideas on this?

Thanks in advance.

Comments (4)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Scott,

Sorry but for now tabs don't support data binding like that. You'd have to programmatically add the ribbon controls you wish to use directly to the ribbon:Group objects you'd put in the ribbon:Tabs. If you have intermediate classes in there like UserControls then variant resizing won't work either.


Actipro Software Support

Posted 13 years ago by Rory Plaire
Avatar
Greetings,

I'm working with Scott on this issue.

We do, in fact, add tabs and groups programmatically to the Ribbon. It appears to me that what is happening is when we programmatically or through a Binding object set the IsSelected property on a Tab, the Tab is no longer selectable from the UI.

I reproduced this behavior by programmatically creating a RibbonWindow, Ribbon and 3 Tabs, adding the Tab objects, and setting the IsSelected value explicitly. The Tab can now no longer be selected by clicking on it with the mouse.

We are currently using WPF Suite 11.1.540, but I think this also was the same behavior we saw in 10.2.533.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Rory,

We have to track our own Tab.IsSelected property separately from Selector.IsSelected since there are some scenarios (like when the Ribbon is minimized) where Selector.IsSelected remains true but Tab.IsSelected changes to be false, which updates the UI appearance.

Since this binding between the two properties is done in the Tab's ControlTemplate.Triggers, setting it programmatically in your code will break this functionality since explicit property setting will always override triggers.

If you need to set an IsSelected property I would recommend you set the Selector.IsSelected attached property instead of the Tab.IsSelected property.


Actipro Software Support

Posted 13 years ago by Rory Plaire
Avatar
Thanks, Support -

Using the Selector.IsSelected property works correctly!

[Modified at 01/21/2011 03:59 PM]
The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.