【问题标题】:How to hide the title of a tab of a LayoutPanel / LayoutDocument?如何隐藏 LayoutPanel / LayoutDocument 的选项卡标题?
【发布时间】:2012-10-19 20:11:50
【问题描述】:

大家早上好!

我在一个项目中使用 AvalonDock,最后我遇到了一个问题:

在我的项目中开发的一些页面中,我有使用标准文本块的自定义标题。在某些页面中,特别是,我在页面左侧锚定了一个 LayoutAnchorable,在右侧锚定了一个 LayoutDocument。

对于 LayoutDocument,标题是空的,因为我在这个页面上已经有了标题。这会导致此 LayoutDocument 选项卡的 TabItem(标题)仍然显示为空值。由于我想在所有页面上保留我的标题,我想知道是否有我如何隐藏或删除这个空白的 tabItem,即标题。我的一个尝试是修改页面的边距,我得到了她的熬夜页面。但是这个 LayoutDocument TabItem 向下重新调整,保持可见。

我知道这不是 AvalonDock 的问题,是原始设计的不同行为。文档的标签标题并不是要隐藏的,但我认为对于那些想要拥有自己的标题页的人来说会很有趣。 最好的问候。

古斯塔沃。

【问题讨论】:

    标签: c# .net tabitem avalondock


    【解决方案1】:

    在 2.0 之前的 AvalonDock 版本中,有一个属性可以满足您的需求。是DocumentPane.ShowHeader

    在 2.0 中,您要么必须重写整个 DockingManager 样式,要么修改 AvalonDock。

    我在问题跟踪器中为此创建了一个问题,并附加了一个补丁,您可以下载该补丁以再次使用。

    此补丁是针对先前版本制作的,如果将其应用于当前版本,可能需要进行一些调整。此外,它不处理此后发布的新主题。

    http://avalondock.codeplex.com/workitem/15626

    补丁:

    Index: AvalonDock/AvalonDock.Theme.VS2010/Theme.xaml
    ===================================================================
    --- AvalonDock/AvalonDock.Theme.VS2010/Theme.xaml   (revision 96146)
    +++ AvalonDock/AvalonDock.Theme.VS2010/Theme.xaml   (working copy)
    @@ -93,7 +93,9 @@
                             </Grid.RowDefinitions>
                             <!--Following border is required to catch mouse events-->
                             <Border Background="Transparent" Grid.RowSpan="2"/>
    -                        <Grid  Panel.ZIndex="1">
    +                        <Grid Grid.Row="0" 
    +                              Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type avalonDockControls:LayoutDocumentPaneControl}}, Path=Model.ShowHeader, Converter={StaticResource BoolToVisibilityConverter}}"  
    +                              Panel.ZIndex="1">
                                 <Grid.ColumnDefinitions>
                                     <ColumnDefinition/>
                                     <ColumnDefinition Width="Auto"/>
    Index: AvalonDock/AvalonDock.Themes.Aero/Theme.xaml
    ===================================================================
    --- AvalonDock/AvalonDock.Themes.Aero/Theme.xaml    (revision 96146)
    +++ AvalonDock/AvalonDock.Themes.Aero/Theme.xaml    (working copy)
    @@ -38,7 +38,9 @@
                             </Grid.RowDefinitions>
                             <!--Following border is required to catch mouse events-->
                             <Border Background="Transparent" Grid.RowSpan="2"/>
    -                        <Grid  Panel.ZIndex="1" >
    +                        <Grid Grid.Row="0"
    +                              Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type avalonDockControls:LayoutDocumentPaneControl}}, Path=Model.ShowHeader, Converter={StaticResource BoolToVisibilityConverter}}"
    +                              Panel.ZIndex="1" >
                                 <Grid.ColumnDefinitions>
                                     <ColumnDefinition/>
                                     <ColumnDefinition Width="Auto"/>
    Index: AvalonDock/AvalonDock/Layout/LayoutDocumentPane.cs
    ===================================================================
    --- AvalonDock/AvalonDock/Layout/LayoutDocumentPane.cs  (revision 96146)
    +++ AvalonDock/AvalonDock/Layout/LayoutDocumentPane.cs  (working copy)
    @@ -49,6 +49,27 @@
                 return true;
             }
    
    +        #region ShowHeader
    +        private bool _showHeader = true;
    +
    +        public bool ShowHeader
    +        {
    +            get
    +            {
    +                return _showHeader;
    +            }
    +            set
    +            {
    +                if (value != _showHeader)
    +                {
    +                    this._showHeader = value;
    +                    RaisePropertyChanged("ShowHeader");
    +                }
    +            }
    +        }
    +
    +        #endregion
    +
             #region SelectedContentIndex
    
             private int _selectedIndex = -1;
    Index: AvalonDock/AvalonDock/Themes/generic.xaml
    ===================================================================
    --- AvalonDock/AvalonDock/Themes/generic.xaml   (revision 96146)
    +++ AvalonDock/AvalonDock/Themes/generic.xaml   (working copy)
    @@ -28,7 +28,9 @@
                             </Grid.RowDefinitions>
                             <!--Following border is required to catch mouse events-->
                             <Border Background="Transparent" Grid.RowSpan="2"/>
    -                        <Grid  Panel.ZIndex="1">
    +                        <Grid Grid.Row="0"
    +                              Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type avalonDockControls:LayoutDocumentPaneControl}}, Path=Model.ShowHeader, Converter={StaticResource BoolToVisibilityConverter}}"
    +                              Panel.ZIndex="1">
                                 <Grid.ColumnDefinitions>
                                     <ColumnDefinition/>
                                     <ColumnDefinition Width="Auto"/>
    

    【讨论】:

      【解决方案2】:

      在当前版本中,您可以添加此代码来隐藏文档的标题:

      <xcad:DockingManager.DocumentTitleTemplate>
          <DataTemplate>
              <Grid/>
          </DataTemplate>
      </xcad:DockingManager.DocumentTitleTemplate>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-12
        • 1970-01-01
        • 2019-10-09
        • 1970-01-01
        相关资源
        最近更新 更多