WPF 4.5 Microsoft's Ribbon: which control of RibbonApplicationMenu

MagB picture MagB · May 8, 2013 · Viewed 8.2k times · Source

I am using Microsoft's Ribbon of WPF 4.5 and developing application using VS2012 (C#) on Win 8 machine. I want to make my application show RibbonApplicationMenu like the "File"-menu of Office Word 2010, but I can't find out which control is used for it (see attached screenshot, red-marked control number 1 and 2). I also tried RibbonApplicationSplitMenuItem but it is more like Office old-style. Maybe anyone can tell me. Thank you in advance.

Which control is used

Answer

Guy picture Guy · May 14, 2013

1) I suggest you use the ribbon that's inside .net 4.5 (add a reference to System.Windows.Controls.Ribbon). I'm not sure what you used the external one. 2)What you need for a menu is Ribbon.ApplicationMenu

3) Below is a working ribbon (based on that) that includes several types of buttons as well as a menu that you require. All you need for this to work is to add an images folder with an "options.png" in it.

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Ribbon  SelectedIndex="0" Grid.Column="0" Grid.ColumnSpan="5">

            <!-- Help Pane, located at the right-hand side -->
            <Ribbon.HelpPaneContent>
                <RibbonButton SmallImageSource="Images\options.png" />
            </Ribbon.HelpPaneContent>

            <!-- Quick Access Toolbar - located at the upper-left corner -->
            <Ribbon.QuickAccessToolBar>
                <RibbonQuickAccessToolBar>
                    <RibbonButton x:Name ="Save" SmallImageSource="Images\options.png" />
                    <RibbonSplitButton x:Name ="Undo" SmallImageSource="Images\options.png" >
                        <RibbonSplitMenuItem Header="Undo 1" />
                        <RibbonSplitMenuItem Header="Undo 2" />
                    </RibbonSplitButton>
                    <RibbonSplitButton x:Name="Redo" SmallImageSource="Images\options.png" >
                        <RibbonSplitMenuItem Header="Redo 1" />
                        <RibbonSplitMenuItem Header="Redo 2" />
                    </RibbonSplitButton>
                    <RibbonCheckBox Label="Sound" KeyTip="X" />
                </RibbonQuickAccessToolBar>
            </Ribbon.QuickAccessToolBar>
            <!-- Application Menu, located at the left-hand side (down arrow) -->
            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu KeyTip="F">
                    <RibbonApplicationMenuItem Header="Options1" ImageSource="Images\options.png" />
                    <RibbonApplicationMenuItem Header="Exit2" ImageSource="Images\options.png" />
                </RibbonApplicationMenu>
            </Ribbon.ApplicationMenu>

            <!-- Ribbon Tab #1: Home -->
            <RibbonTab Header="Home" KeyTip="H" >

                <!-- Home  group-->
                <RibbonGroup x:Name="ClipboardGroup" Header="Home">
                    <RibbonMenuButton LargeImageSource="Images\options.png" Label="Activate" KeyTip="V">
                        <RibbonToggleButton SmallImageSource="Images\options.png" Label="blabla" KeyTip="H" />
                        <RibbonToggleButton SmallImageSource="Images\options.png" Label="option2" />
                    </RibbonMenuButton>
                    <RibbonToggleButton SmallImageSource="Images\options.png" Label="Toggle " KeyTip="X" />
                    <RibbonToggleButton x:Name="Toggle11" SmallImageSource="Images\options.png" Label="Just a Toggle" KeyTip="FP" />

                </RibbonGroup>

                <!-- Employee And Payroll group-->
                <RibbonGroup x:Name="Employee" Header="Adjust View">
                    <RibbonMenuButton LargeImageSource="Images\options.png" Label="Test" KeyTip="V">
                        <RibbonMenuItem ImageSource="Images\options.png" Header="Keep Text Only" KeyTip="T"/>
                        <RibbonMenuItem ImageSource="Images\options.png" Header="Paste Special..." KeyTip="S"/>
                    </RibbonMenuButton>
                    <RibbonCheckBox SmallImageSource="Images\options.png" Label="Sound" KeyTip="X" />

                </RibbonGroup>


            </RibbonTab>

            <!-- Ribbon Tab #2: Launch -->
            <RibbonTab Header="Settings" KeyTip="I">
                <!-- Launch/Applications group-->
                <RibbonGroup Header="Settings">
                    <RibbonButton SmallImageSource="Images\options.png" Label="Record" KeyTip="C" />
                </RibbonGroup>

            </RibbonTab>
            <RibbonTab Header="PageLayout" KeyTip="L">
                <!-- Launch/Applications group-->
            </RibbonTab>
        </Ribbon>
    </Grid>
</Window>