1

Good morning everyone!

I'm using the AvalonDock on a project, and I ended having a question:

In some pages developed in my project, I have custom titles which use a standard textBlock. And in some pages, this specifically, I have a LayoutAnchorable anchored on the left side of the page, and a LayoutDocument anchored on the right side.

For LayoutDocument, the title is empty, because I already have a title on this page. This causes the TabItem (Title) of this LayoutDocument Tab still appears with empty value. As I would like to maintain my titles on all pages, I wonder if there is how I hide or remove this blank tabItem, which is the title. One of my attempts was modify the margin of the page, I got her stay up page. But this LayoutDocument TabItem is readjusted downward, keeping it visible.

I know this is not a problem AvalonDock, is a different behavior of the original design. The tab Title of the document was not meant to be hidden, but I think it would be interesting for those who want to have their own title pages. Best Regards.

Gustavo.

Gustavo Gonçalves
  • 528
  • 1
  • 12
  • 33

2 Answers2

0

There was a property to do just what you want in AvalonDock versions prior to 2.0. It was DocumentPane.ShowHeader

In 2.0, you either have to rewrite the entire DockingManager Style, or modify AvalonDock.

I created an issue for this in the issue tracker, and attached a patch that you can download to have to feature again.

This patch was made against a prior version, and might need some tweaking if you apply it to current version. Also, it does not handle new themes that were released since then.

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

Patch:

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"/>
Jf Beaulac
  • 5,206
  • 1
  • 25
  • 46
0

In the current version, you can add this code to hide documents' titles:

<xcad:DockingManager.DocumentTitleTemplate>
    <DataTemplate>
        <Grid/>
    </DataTemplate>
</xcad:DockingManager.DocumentTitleTemplate>
Sasino
  • 134
  • 2
  • 11