data binding backstage items

Ribbon for WPF Forum

Posted 11 years ago by Bitmasterq
Version: 12.2.0571
Avatar

Hi,

We want to set the content of the backstage menu through data binding using an ObservableCollection with one view model per backstage item. We managed to get backstage items using the folowing item container style:

<Style x:Key="backstageItemStyle" TargetType="{x:Type ribbon:BackstageTab}">
<Setter Property="Header" Value="{Binding Header}" />
<Setter Property="Content" Value="{Binding Content}" />
<Setter Property="KeyTipAccessText" Value="{Binding Shortcut}" />
</Style>

 

Content is a User Control. The ApplicatioMenu is defined like this:

<ribbon:Ribbon.ApplicationMenu>
<ribbon:Backstage x:Name="appMenu" ItemsSource="{Binding BackstageControls}" ItemContainerStyle="{StaticResource backstageItemStyle}">
</ribbon:Backstage>
</ribbon:Ribbon.ApplicationMenu>

 

What we need help with is adding buttons and separators to the Backstage Menu. It seems that every view model in the BackstageControls collection is always rendered inside a BackstageTab. How do we do this?

Comments (1)

Answer - Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi,

Backstage works like any other ItemsControl where there is a default item it creates for data bound items.  In this case it is a BackstageTab, which is done in the Backstage.GetContainerForItemOverride method.  Our IsItemItsOwnContainerOverride implementation does allow for ribbon:Button and ribbon:Separator though.

But what you'd need to do is pass those through in your items you are binding.  So your data items would then get wrapped by the BackstageTab.  And the ribbon:Button and ribbon:Separator items would remain as-is, since they are allowed.

I don't think WPF allows another way to do this.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.