WPF Ribbon - Hide quick access toolbar

杀马特。学长 韩版系。学妹 提交于 2019-12-05 12:17:30

问题


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


回答1:


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.




回答2:


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);
  }
}




回答3:


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>



回答4:


Here is the solution :

this.ribbonControl1.ToolbarLocation = DevExpress.XtraBars.Ribbon.RibbonQuickAccessToolbarLocation.Hidden;



回答5:


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




回答6:


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>


来源:https://stackoverflow.com/questions/6265392/wpf-ribbon-hide-quick-access-toolbar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!