15

how do you hide Quick Access Toolbar in a WPF's Ribbon?

redman
  • 2,115
  • 5
  • 32
  • 59
  • 1
    Do you want there to never be a Quick Access Toolbar, or are you looking for show/hide functionality? I'm using the Microsoft Ribbon, and I have no buttons in my QAT by default and nothing shows up there. – Scott Jun 07 '11 at 14:17
  • 2
    I want to permanently hide it. That's probably because you use RibbonWindow and I use normal Windows, because RibbonWindow looks like a piece of s.. in Win XP. – redman Jun 07 '11 at 16:58
  • 3
    Gotchya... I do use RibbonWindow. And I agree... looks terrible in XP. – Scott Jun 07 '11 at 18:32

6 Answers6

44

For Microsoft Ribbon for WPF, you can hide it by using the VisualTreeHelper. On the Loaded event handler, just resize the row containing the Quick Access Toolbar to 0 :

private void RibbonLoaded(object sender, RoutedEventArgs e)
{
  Grid child = VisualTreeHelper.GetChild((DependencyObject)sender, 0) as Grid;
  if (child != null)
  {
    child.RowDefinitions[0].Height = new GridLength(0);
  }
}

enter image description here

Philippe Lavoie
  • 2,583
  • 5
  • 25
  • 39
13

The Quick Access Toolbar is automatically hidden when the Ribbon control is in a RibbonWindow. When it is not, it seems impossible to hide it. I have already worked hours on this issue and was unable to hide it properly. But there is one simple workaround: Place the Ribbon control inside of a Panel and give it a negative top margin so it will slide outside of the Panel. Set the Panel's ClipToBounds property to true and the QAT will be hidden. By the way - there are multiple Ribbon implementations for WPF, even by Microsoft themselves ("Fluent Ribbon" and "Microsoft Ribbon for WPF"), so next time you should mention which one you are talking about.

Libor
  • 3,285
  • 1
  • 33
  • 41
Daniel Albuschat
  • 806
  • 8
  • 20
  • It's WPF Ribbon preview from http://wpf.codeplex.com/wikipage?title=WPF%20Ribbon%20Preview – redman Jul 05 '11 at 11:10
  • 2
    Just a note if you started with a stock RibbonWindow as I did: I changed the window type to Window in both XAML and code-behind, added ClipToBounds="true" to the LayoutRoot grid, and gave the ribbon a top margin of -22. – Sean Mar 07 '12 at 20:13
  • @Sean yeah, the value of -22 seems to be the right one. – Xam Oct 02 '19 at 17:58
1

Or if you want it all in the XAML, this works

<ribbon:Ribbon>
    <ribbon:Ribbon.Loaded>CollapseQuickAccessToolbar</ribbon:Ribbon.Loaded>
    <x:Code>
        private void CollapseQuickAccessToolbar(Object sender, RoutedEventArgs e) {
            ((Grid)VisualTreeHelper.GetChild((DependencyObject)sender, 0)).RowDefinitions[0].Height = new GridLength(0);
        }
    </x:Code>
</ribbon:Ribbon>
Nick Strupat
  • 4,928
  • 4
  • 44
  • 56
0

Here is the solution :

this.ribbonControl1.ToolbarLocation = DevExpress.XtraBars.Ribbon.RibbonQuickAccessToolbarLocation.Hidden;
Tunaki
  • 132,869
  • 46
  • 340
  • 423
-1

I know this is an old post, but found an easier solution... Add this inside the ribbon :-

<ribbon:Ribbon.QuickAccessToolBar>
    <ribbon:RibbonQuickAccessToolBar Visibility="Collapsed"/>
</ribbon:Ribbon.QuickAccessToolBar>
Dipu
  • 41
  • 1
  • Doesn't work for me. Is there something else that needs done? – psubsee2003 Oct 05 '14 at 11:04
  • @psubsee2003 : By setting this property, I was able to hide the tool bar. I also set the context menu to "{x:Null}" at ribbon, button group and button levels to disable the context menu. – Dipu Oct 13 '14 at 15:15
-1

Bit late to the party.

<my:Ribbon   >
            <my:Ribbon.ApplicationMenu >
                <my:RibbonApplicationMenu Visibility="Collapsed">
                </my:RibbonApplicationMenu>
            </my:Ribbon.ApplicationMenu>

This will help to hide the quick bar

  • The question was regarding Quick Access Toolbar, not the Application Menu. And no, collapsing Application Menu does not hide the Quick Access Toolbar. – RollerMobster Mar 25 '22 at 12:14