How To Close Backstage Tab

Ribbon for WPF Forum

Posted 9 years ago by Andy Ver Murlen
Version: 10.2.0532
Avatar
How do you close the backstage menu in code? Setting MyRibbon.IsApplicationMenuOpen seems to have no effect opening it or closing it.

I have a scenario where a user clicks a button to perform a task, and at the end of the task, I want to close the menu without the user having to interact.

Comments (6)

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

In a test I just did, doing this closed the Backstage fine:
ribbon.IsApplicationMenuOpen = false;


Actipro Software Support

Posted 9 years ago by Andy Ver Murlen
Avatar
I have done some further investigating, and it appears that setting IsApplicationMenuOpen does work....occasionally. There are some major consistency issues with it.

For example, in the simplest way to to set it (IsApplicationMenuOpen is set in the xaml of the Ribbon), it does not work. Consider the following, the window opens with no tabs displayed at all....

<ribbon:RibbonWindow 
    x:Class="TestAPp.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
    >
    <Grid x:Name="uxGrid_MainGrid" Margin="6" SnapsToDevicePixels="True">
        <DockPanel SnapsToDevicePixels="True" LastChildFill="True">

            <!-- Ribbon -->
            <ribbon:Ribbon 
                x:Name="uxRibbon"
                DockPanel.Dock="Top"
                TargetContentContainer="{Binding ElementName=uxGrid_MainGrid}"
                IsApplicationButtonVisible="True"
                ApplicationButtonLabel="File"
                IsQuickAccessToolBarCustomizeButtonVisible="False"
                IsMinimizable="True"
                SnapsToDevicePixels="True"
                UseScenicLayout="True"
                IsApplicationMenuOpen="True"
                >
                <ribbon:Ribbon.ApplicationMenu>
                    <ribbon:Backstage x:Name="uxBackstage">
                        <ribbon:Button 
                            Label="Exit" 
                            SnapsToDevicePixels="True"
                            ScreenTipDescription="Exit the application."
                            />
                    </ribbon:Backstage>
                </ribbon:Ribbon.ApplicationMenu>

                <ribbon:Ribbon.Tabs>

                    <ribbon:Tab x:Name="uxRibbonTab_Edit" Label="Edit" Id="Edit" SnapsToDevicePixels="True">
                        <ribbon:Group Label="My Stuff">
                            <ribbon:Button 
                                Label="Do Something"
                                />                           
                        </ribbon:Group>
                    </ribbon:Tab>
                </ribbon:Ribbon.Tabs>
            </ribbon:Ribbon>
        </DockPanel>
    </Grid>
</ribbon:RibbonWindow>
When I started looking into this issue, I simply set this as a test and it didn't work. That's what threw me.
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Correct, it probably will not work if set in XAML to true like that. The application menu is not designed to be opened by default. You'd have to set that property programmatically after everything has been loaded to have it work correctly.


Actipro Software Support

Posted 9 years ago by Andy Ver Murlen
Avatar
Going the other way, how can I prevent the backstage menu from being closed when a button in the menu is clicked?

I am building my own recent document manager (yours doesn't suit my purposes). I have everything working the way I want, except when the user clicks my "toggle pin" button, it executes my command in my viewmodel, then the backstage menu closes. I need to prevent this.

I have tried setting IsApplicationMenuOpen to true immediately after executing my command code. However, all this does not work, and in fact blanks out all tabs until another one is clicked.
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Andy,

You can probably set StaysOpenOnClick="True" on the buttons to prevent the close.


Actipro Software Support

Posted 9 years ago by Andy Ver Murlen
Avatar
Thanks, I knew there would be something, but I couldn't find it.
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.