PopupButton direction when in ApplicationMenu

Ribbon for WPF Forum

Posted 9 years ago by Keith I
Version: 10.2.0531
Avatar
If I create a PopupButton and add it to the ApplicationMenu then the arrow is to the right of the button and the popup contents are shown to the right. This is correct.

If I create a view-model class for a popup-button, add a DataTemplate to map it to a PopupButton and set the ApplicationMenu.ItemsSource to a list of my view-model objects, then the arrow is at the bottom of the button and the popup contents are shown at the bottom (in the same way as you would expect if a PopupButton is shown in the ribbon). In this scenario, is there any way to get the arrow to appear on the right, or have I done something wrong?

My DataTemplate is as follows:
<DataTemplate DataType="{x:Type MyViewModel}">
    <ribbon:PopupButton>
        <ribbon:PopupButton.PopupContent>
            <ribbon:Menu ItemsSource="{Binding Items}" />
        </ribbon:PopupButton.PopupContent>
    </ribbon:PopupButton>
</DataTemplate>
And my code is:
List<MyViewModel> Buttons = new List<MyViewModel>;
Buttons.Add(new MyViewModel());
TheRibbon.ApplicationMenu.ItemsSource = Buttons;

Comments (5)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Keith,

You can set Context="MenuItem" VariantSize="Large" on the PopupButton tag to get the desired style.


Actipro Software Support

Posted 9 years ago by Keith I
Avatar
Thank you for the quick response. That works.

However, I now have the problem whereby popup-buttons in the ribbon have a right-arrow, when I want them to have a down-arrow. Can you think of a way to set the DataTemplate such that the button appears with a down-arrow in the ribbon and with a right-arrow in the application menu? Bear in mind that at times I am adding a single MyViewModel instance to both ribbon and application menu.
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Keith,

Do you have a simple sample project you could whip together to show this and perhaps we can see if there's anything we can do to get it working? If so, please ZIP it up (without any .exe files), rename the ZIP, and email it to us. Please reference this post in your email. Thanks!


Actipro Software Support

Posted 9 years ago by Keith I
Avatar
I've managed to sort it out. I just created a separate DataTemplate for the application menu. Thanks for your help.

However, I now have a similar question related to the new Backstage control, which I want to switch over to using. I have some buttons on the Backstage control (created from a DataTemplate) but they always appear as Backstage tabs (like New and Print in your sample). What should the Context be to make them show as buttons (like the Open and Save buttons in your sample)?

The DataTemplate is:
<DataTemplate DataType="{x:Type MyButtonViewModel}">
    <ribbon:Button/>
</DataTemplate>
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Keith,

You'd want to use Context="BackstageHeaderItem" to get the normal look for buttons there.

However if you are passing data items, it likely is wrapping them with a BackstageTab, which is why you see the tabs. You might need to inherit Backstage and override GetContainerForItemOverride to use ribbon:Button instead of BackstageTab for the appropriate data items.


Actipro Software Support

The latest build of this product (v2019.1 build 0681) 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.