Switching between Backstage and Traditional Menu view.

Ribbon for WPF Forum

Posted 12 years ago by Adam Davis
Version: 12.1.0562
Avatar

Guys is there anyway to switch between Backstage and Traditional Menu view when selecting themes. I love that users can select either the classic 2007 look or the newer looks but the backstage menuseems to always stay. I saw that you can create the Traditional menu by using <ribbon:ApplicationMenu> But this makes it difficult to implement a switch based on the users selection.

I suppose I could design two menus and collapse one while in backstage, switching when the user selects the 2007 style.

Comments (11)

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

Hi Adam,

You should be able to swap in a ribbon:ApplicationMenu instance when you select the older themes and then the ribbon:Backstage instance when you are in the newer themes.  You'd have to do that swap programmatically but it's just a matter of setting the ApplicationMenu property on the Ribbon.


Actipro Software Support

Posted 12 years ago by Adam Davis
Avatar

Apparently I'm not following correctly can you give me an example in xml?

I'm trying something like 

<ribbon:Ribbon.ApplicationMenu>
                <Grid>
                    <ribbon:ApplicationMenu x:Name="appMenu"
                                            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                            ScrollViewer.VerticalScrollBarVisibility="Disabled">
                        <!--  ApplicationMenu Exit Button  -->
                        <ribbon:Button Command="commands:ApplicationCommands.ApplicationExit"
                                   KeyTipAccessText="X"
                                   Label="Exit">
                            <ribbon:Button.ImageSourceSmall>
                                <BitmapImage UriSource="pack://application:,,,/MHManager;component/Resources/Images/Close_Box_Red_16.png" />
                            </ribbon:Button.ImageSourceSmall>
                        </ribbon:Button>
                    </ribbon:ApplicationMenu>
 
                <!-- BackStage menu here -->
                <ribbon:Backstage x:Name="BackStageMenu"
                                  ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                  ScrollViewer.VerticalScrollBarVisibility="Disabled" >
                    <!--  NOTE: Put your own background watermark here  -->
                    <ribbon:Backstage.Background>
                        <ImageBrush AlignmentX="Right"
                                    AlignmentY="Bottom"
                                    ImageSource="pack://application:,,,/MHManager;Component/Resources/Images/BackstageBackground.png"
                                    Stretch="None"
                                    TileMode="None" />
                    </ribbon:Backstage.Background>
              </Grid> 
 </ribbon:Ribbon.ApplicationMenu>

 Which is having both inside the Ribbon.ApplicationMenu.

 

I think I understand that I would just set which one the ribbon uses by setting the ApplicationMenu value to something like

ribbon.ApplicationMenu = Backstagemenu;

Which would represent the x:Name of the BackstageMenu

 

ribbon.ApplicationMenu = appMenu;

Would be the x:Name of the application Menu. Am I correct?

If so how do I create two separate menus? A style perhaps? could you point me to an example?

 

The code above gives me an error however. I know thats not the proper way.

[Modified 12 years ago]

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

Hi Adam,

You can't do what you are doing in XAML there since it needs to be either the ApplicationMenu or Backstage that is directly assigned to the Ribbon.ApplicationMenu property.

A better setup would be to perhaps keep one of them in place here in your main XAML (whichever will be the default).  Then split out the other one to its own class (like MyAppMenu : ApplicationMenu) that has XAML tied to it similar to how a UserControl works.  And create and swap in an instance of that as needed.


Actipro Software Support

Posted 12 years ago by Adam Davis
Avatar

ok I have setup a seperate form basically this 

<ribbon:Backstage x:Class="Test.MenuTemplates.Office2010Backstage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Button Content="Testing" />
    
</ribbon:Backstage>

 The Code behind is this 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ActiproSoftware.Windows.Controls.Ribbon;
using ActiproSoftware.Windows.Controls.Ribbon.Controls;

namespace Test.MenuTemplates
{
    /// <summary>
    /// Interaction logic for Office2010Backstage.xaml
    /// </summary>
    public partial class Office2010Backstage : Backstage
    {
        public Office2010Backstage()
        {
            InitializeComponent();
        }
    }
}

 now on my main form hosting the ribbon I have in code tried to assign ribbon.ApplicationMenu to this Template like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ActiproSoftware.Windows.Themes;
using ActiproSoftware.Windows.Controls;
using ActiproSoftware.Windows.Controls.Ribbon;
using RibbonControls = ActiproSoftware.Windows.Controls.Ribbon.Controls;
using ActiproSoftware.Windows.DocumentManagement;
using Test.MenuTemplates;

namespace Test
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RibbonWindow
    {
        

        public MainWindow()
        {
            Office2010Backstage appMenu = new Office2010Backstage();
            ribbon.ApplicationMenu = appMenu;

            InitializeComponent();
        }
    }
}

 This of course gives me an error. Mind you I'm just trying to figure out what exatly you mean on how to split this like you said.

Posted 12 years ago by Adam Davis
Avatar

Feeling real dumb here guys. Thought I was making great progress understanding this control but now I'm just not grasping setting up a switchable menu style between backstage and Traditional 2007 menu.

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

Hi Adam,

What you have looks good overall, but keep in mind that InitializeComponent needs to be called in MainWindow's constructor before you try to access ribbon.  Otherwise the ribbon variable is probably null at that point.  Does that help?


Actipro Software Support

Posted 12 years ago by Adam Davis
Avatar

Ok that fixed it duh!

Posted 12 years ago by Adam Davis
Avatar

One more question guys How do I swap back to the original menu in my Xaml? 

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

Hi Adam,

You could give the original XAML one an x:Name and then it might save that as a field so that you can restore it from that field again later.


Actipro Software Support

Posted 12 years ago by Adam Davis
Avatar

Yeah I did, but I'm trying to switch it from a popup options window. The error I get is: Specified element is already the logical child of another element. Disconnect it first.

How do I disconnect it to reconnect it?

[Modified 12 years ago]

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

Hi Adam,

I'm not really sure what you are running into but it's something where you are trying to set something in the visual hierarchy that is already located in the visual hierarchy elsewhere. 

When I try the concept I mentioned from our demo, it works fine.  I did this in one of the button command handlers in our main Features demo:

if (ribbon.ApplicationMenu == appMenu)
	ribbon.ApplicationMenu = new ActiproSoftware.Windows.Controls.Ribbon.Controls.ApplicationMenu();
else
	ribbon.ApplicationMenu = appMenu;


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.