WPF 功能区 - 隐藏快速访问工具栏

发布于 2024-11-14 16:15:34 字数 30 浏览 2 评论 0原文

如何在 WPF 的功能区中隐藏快速访问工具栏?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

遇到 2024-11-21 16:15:34

对于 Microsoft Ribbon for WPF,您可以隐藏通过使用 VisualTreeHelper 来实现。在 Loaded 事件处理程序中,只需将包含快速访问工具栏的行大小调整为 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);
  }
}

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

不必你懂 2024-11-21 16:15:34

当 Ribbon 控件位于 RibbonWindow 中时,快速访问工具栏会自动隐藏。如果不是,似乎就不可能隐藏它。我已经在这个问题上工作了几个小时,但无法正确隐藏它。
但有一个简单的解决方法:将 Ribbon 控件放置在面板内,并给它一个负的上边距,这样它就会滑到面板之外。将面板的 ClipToBounds 属性设置为 true,QAT 将被隐藏。
顺便说一句 - WPF 有多种功能区实现,甚至是 Microsoft 自己实现的(“Fluent Ribbon”和“Microsoft Ribbon for WPF”),所以下次您应该提及您正在谈论的是哪一个。

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.

小矜持 2024-11-21 16:15:34

或者,如果您希望将所有内容都包含在 XAML 中,则可以这样做

<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>

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>
没有伤那来痛 2024-11-21 16:15:34

这是解决方案:

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

Here is the solution :

this.ribbonControl1.ToolbarLocation = DevExpress.XtraBars.Ribbon.RibbonQuickAccessToolbarLocation.Hidden;
两仪 2024-11-21 16:15:34

我知道这是一篇旧文章,但找到了一个更简单的解决方案......
将其添加到功能区中:-

<ribbon:Ribbon.QuickAccessToolBar>
    <ribbon:RibbonQuickAccessToolBar Visibility="Collapsed"/>
</ribbon:Ribbon.QuickAccessToolBar>

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>
辞慾 2024-11-21 16:15:34

聚会有点晚了。

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

这将有助于隐藏快捷栏

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文