Articles in this section
Category / Section

How to add a new button in the document state of DockingManager?

1 min read

In DockingManager, you can add a new button in the Document state by using the IsNewButtonEnabled property of the DocumentTabControl. To achieve this, you need to fetch the DocumentTabControl from the DockingManager and set the IsNewButtonEnabled property. Refer to the following code examples.

XAML

//The following code shows how the children of the DockingManager had added
<Window x:Class="WpfApplication24.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 Name="Docking" UseDocumentContainer="True">
            <ContentControl syncfusion:DockingManager.Header="Document1" syncfusion:DockingManager.State="Document"/>
            <ContentControl syncfusion:DockingManager.Header="Document2" syncfusion:DockingManager.State="Document"/>
            <ContentControl syncfusion:DockingManager.Header="Document3" syncfusion:DockingManager.State="Document"/>
</syncfusion:DockingManager>
    </Grid>
</Window>

C#

//The following code snippet explains how the IsNewButtonEnabled property is applied for the tabcontrol
using Syncfusion.Windows.Tools.Controls;
using Syncfusion.Windows.Shared;
namespace WpfApplication24
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            (Docking.DocContainer as DocumentContainer).Loaded += new RoutedEventHandler(MainWindow_Loaded);       
        }
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
//This code represents the tabcontrol is fetched from the DockingManager            
DocumentTabControl tabcontrol = VisualUtils.FindDescendant(Docking.DocContainer as Visual, typeof(DocumentTabControl)) as DocumentTabControl;
            if (tabcontrol != null)
            {     
//This code shows how the NewButtonEnabled property is set for the tabcontrol           
                tabcontrol.IsNewButtonEnabled = true;
                tabcontrol.NewButtonClick += tabcontrol_NewButtonClick;              
            }
        }
        void tabcontrol_NewButtonClick(object sender, EventArgs e)
        {
            MessageBox.Show("NewButton clicked");
        }   }    

 

Output:

The following screenshot displays how the New Button is added in the DockingManager.

 

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