Category / Section
How to hide the header for the tabbed children in WPF DockingManager?
1 min read
The dock header of the Tabbed children in the WPF DockingManager can be hidden by setting NoHeader property as True. Tabbed children can be fetching from the DockedElementTabbedHost in the DockingManager’s MouseUp event by checking its state is Dock state.
The same has been explained in the following code snippet:
XAML:
<Window x:Class="DockingManager.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:syncfusion="http://schemas.syncfusion.com/wpf" Title="MainWindow" Height="350" Width="525"> <Grid> <syncfusion:DockingManager x:Name="DockingManager1" UseDocumentContainer="True" DockTabAlignment="Top" > <ContentControl x:Name="content1" syncfusion:DockingManager.Header="Dock1" syncfusion:DockingManager.State="Dock" > </ContentControl> <ContentControl x:Name="content2" syncfusion:DockingManager.Header="Dock2" syncfusion:DockingManager.State="Dock"></ContentControl> <ContentControl x:Name="content3" syncfusion:DockingManager.Header="Dock3" syncfusion:DockingManager.State="Dock"></ContentControl> <ContentControl x:Name="content4" syncfusion:DockingManager.Header="Dock4" syncfusion:DockingManager.State="Dock"></ContentControl> </syncfusion:DockingManager> </Grid> </Window>
C#
using Syncfusion.Windows.Shared; using Syncfusion.Windows.Tools.Controls; namespace DockingManager { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DockingManager1.MouseUp += DockingManager1_MouseUp; } private void DockingManager1_MouseUp(object sender, MouseButtonEventArgs e) { if (DockingManager1.ActiveWindow != null) { DockState state = DockingManager.GetState(DockingManager1.ActiveWindow); if (state == DockState.Dock) { DockedElementTabbedHost host = DockingManager.GetHost(DockingManager1.ActiveWindow, state); if (host != null) { host.TabChildren.CollectionChanged += TabChildren_CollectionChanged; if (host.TabChildren.Count > 1) { foreach (var child in host.TabChildren) { //Setting SetNoHeader property for the Tab children DockingManager.SetNoHeader(child as DependencyObject, true); } } else { foreach (var child in host.TabChildren) { DockingManager.SetNoHeader(child as DependencyObject, false); } } } } } } void TabChildren_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if ((sender as ObservableCollection<FrameworkElement>).Count == 1) { DockingManager.SetNoHeader((sender as ObservableCollection<FrameworkElement>)[0],false); } } } }
The following screenshot shows the dock header for the tabbed children get hidden in the DockingManager.