Articles in this section
Category / Section

How to set Newbutton properties of DocumentTabControl in DockingManager using style?

3 mins read

You can set the NewButton properties of the DocumentTabControl in WPF Docking by overriding the themes to the control’s style. This can be achieved by adding a corresponding ResourceDictionary in the sample and defining the new style with the BasedOn property. When the ResourceDictionary is added, you can acquire all the settings of the base style, and you can override them as desired. Using this approach, you can override the style for all the controls. An example is illustrated here to set the NewButton properties for the DocumentTabControl by customizing the DocumentTabControlStyle using the BasedOn property.

Syntax for ResourceDictionary

<ResourceDictionary Source="/Syncfusion.Themes.FluentDark.WPF;component/<ControlName>/<ControlName>.xaml">
</ResourceDictionary>

Step 1 : Add the resource dictionary in MainWindow.xaml.

<Window.Resources>
   <ResourceDictionary>
       <ResourceDictionary.MergedDictionaries>
           <ResourceDictionary Source="/Syncfusion.Themes.FluentDark.WPF;component/DockingManager/DockingManager.xaml" />
       </ResourceDictionary.MergedDictionaries>
       <Style x:Key="documenttab" TargetType="{x:Type syncfusion:TabControlExt}" BasedOn="{StaticResource SyncfusionDocumentTabControlExtStyle}">
           <Setter Property="IsNewButtonEnabled" Value="True"/>
       </Style>
   </ResourceDictionary>
</Window.Resources>

Syntax for BasedOn

BasedOn="{StaticResource Syncfusion<ControlName>Style}"

Step 2 : Define the new style using the BasedOn property.

<Window x:Class="WpfApp6.MainWindow"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       xmlns:local="clr-namespace:WpfApp6" xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
       mc:Ignorable="d"
       Title="MainWindow" Height="450" Width="800">
   <Window.Resources>
       <ResourceDictionary>
           <ResourceDictionary.MergedDictionaries>
               <ResourceDictionary Source="/Syncfusion.Themes.FluentDark.WPF;component/DockingManager/DockingManager.xaml" />
           </ResourceDictionary.MergedDictionaries>
           <Style x:Key="documenttab" TargetType="{x:Type syncfusion:TabControlExt}" BasedOn="{StaticResource SyncfusionDocumentTabControlExtStyle}">
               <Setter Property="IsNewButtonEnabled" Value="True"/>
               <Setter Property="NewButtonAlignment" Value="First"/>
               <Setter Property="SelectOnCreatingNewItem" Value="True"/>
               <Setter Property="IsNewButtonClosedonNoChild" Value="False"/>
               <Setter Property="NewButtonBackground" Value="Red"/>
               <Setter Property="NewButtonBorderThickness" Value="2"/>
           </Style>
       </ResourceDictionary>
   </Window.Resources>
   <Grid>
       <syncfusion:DockingManager x:Name="PART_DockingManager"
                  UseDocumentContainer="True"
                  DocumentCloseButtonType="Individual"
                  syncfusion:DockingManager.DocumentTabControlStyle="{StaticResource documenttab}">
   <ContentControl syncfusion:DockingManager.Header="Docking 1" syncfusion:DockingManager.State="Document" />
   <ContentControl syncfusion:DockingManager.Header="Docking 2" syncfusion:DockingManager.State="Document" />
</syncfusion:DockingManager>
   </Grid>
</Window>
      

Conclusion

​I hope you enjoyed learning how to set the NewButton properties of the DocumentTabControl in WPF DockingManager.

​You can refer to our WPF Docking feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

​For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

​If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

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