WPF Ribbon - 隐藏标签页眉(单标签应用程序) [英] WPF Ribbon - hiding tab header (single tab application)

查看:70
本文介绍了WPF Ribbon - 隐藏标签页眉(单标签应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 WPF 的新手,正在尝试使用功能区控件.

I am new to WPF and am trying to use the Ribbon control.

我在应用程序中有一个选项卡,希望隐藏标题但仍显示选项卡本身.

I have a single tab in the application, and wish to hide the header but still show the tab itself.

我一直在尝试各种属性和样式,但我只能隐藏整个选项卡.

I have been experimenting with various properties and styles, but I have only been able to hide the entire tab.

我尝试过:ribbontab 可见性、ribbontab.header 可见性、在 TabHeaderItemCollection 中设置隐藏、将样式 xaml 应用于ribbontab 中的ribbontabheader 元素、试验tabheadertemplate 属性,并且通常通过api 筛选寻找任何可能相关的东西.

I've tried: ribbontab visibility, ribbontab.header visibility, setting hidden in TabHeaderItemCollection, applying style xaml to ribbontabheader element in ribbontab, experimenting with tabheadertemplate property, and generally sifting through the api looking for anything that may be relevant.

Google 只显示如何隐藏整个标签.

Google only turns up how to hide the whole tab.

还有其他想法吗?

推荐答案

通过将控件向上移动 47 个像素,我设法隐藏了选项卡标题和应用程序菜单...

I managed to hide both the tab headers and the application menu by shifting the control 47 pixels upwards...

<r:Ribbon Margin="0,-47,0,0" DockPanel.Dock="Top" x:Name="ribbon">

注意:您可以通过执行此操作仅隐藏应用程序菜单而不隐藏选项卡...

Note: you can hide just the application menu and not the tabs by doing this...

<r:Ribbon DockPanel.Dock="Top" x:Name="ribbon">             
    <r:Ribbon.ApplicationMenu>
        <r:RibbonApplicationMenu Visibility="Collapsed" />
    </r:Ribbon.ApplicationMenu>

只隐藏标签页头,我做不到.通过如下覆盖功能区类,我确实非常接近...

Hiding just the tab headers, I can't quite do. I did get pretty close by overriding the ribbon class as follows...

class RibbonNoTab : Ribbon
{
    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();

        var ctrl = this.GetDescendants<Grid>().FirstOrDefault();
        if (ctrl != null)
        {
            ctrl.RowDefinitions[1].Height = new GridLength(0, System.Windows.GridUnitType.Pixel);
        }
    }
}

GetDescendants 扩展方法只是在可视化树中搜索指定类型的内容.它取自此处:http://blog.falafel.com/finding-controls-by-type-in​​-silverlight-and-wpf/

The GetDescendants extension method just searches the visual tree for something of a specified type. It was taken from here: http://blog.falafel.com/finding-controls-by-type-in-silverlight-and-wpf/

上述方法的唯一问题是看起来像剩余 1 像素高的条.你必须仔细观察才能看到它!

The only issue with the above method was that there looks like a 1 pixel high bar remaining. You have to look pretty closely to see it!

这篇关于WPF Ribbon - 隐藏标签页眉(单标签应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆