Articles in this section
Category / Section

How to remove space between header and content of TabItem in WPF DockingManager?

1 min read

You can reduce the space between TabItem header and the content of the TabItem by customizing the margin value of the ContentPresenter(“PART_SelectedContentHost”) in which we have placed the actual content of TabItem in WPF DockingManager. The following code example demonstrate the same,

Mainwindow.xaml

<syncfusion:DockingManager x:Name="_Docking" UseDocumentContainer="True" syncfusion:SkinStorage.VisualStyle="Metro">                    
  <ContentControl syncfusion:DockingManager.Header="Dock1" Background="Brown" syncfusion:DockingManager.State="Document">
    <TextBlock Background="Brown"></TextBlock>
  </ContentControl>
  <ContentControl syncfusion:DockingManager.Header="Dock2" syncfusion:DockingManager.State="Document">
    <TextBlock Background="Green" ></TextBlock>
  </ContentControl>
  <ContentControl syncfusion:DockingManager.Header="Dock3" syncfusion:DockingManager.State="Document">
    <TextBlock Background="Red"></TextBlock>
  </ContentControl>
</syncfusion:DockingManager>

Mainwindow.cs

public partial class MainWindow : Window
{
 public MainWindow()
 {
  InitializeComponent();            
  (Docking.DocContainer as DocumentContainer).Loaded += MainWindow_Loaded;
 }
 
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
  DocumentTabControl tabcontrol = VisualUtils.FindDescendant(Docking, typeof(DocumentTabControl)) as DocumentTabControl;
  if (tabcontrol != null)
  {
    ContentPresenter content = tabcontrol.Template.FindName("PART_SelectedContentHost", tabcontrol) as ContentPresenter;               
    if (content != null && !content.Margin.Equals(new Thickness(0)))
    {
      content.Margin = new Thickness(0);
    }
  }
 }       
}

The following screenshot shows the default layout of the Document window,

Default layout of document window in WPF DockingManager

The following screenshot shows the output of the above code,

Default layout of document window in WPF DockingManager

View sample in GitHub.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied