We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to disable the close button of MDI windows in WPF DockingManager?

Platform: WPF |
Control: DockingManager |
Published Date: December 9, 2015 |
Last Revised Date: August 3, 2021 |
.NET Framework: 4.5

To disable the close button for the MDI window, the CanClose an attached property of WPF DockingManager need to set to False for the particular document window. The same has been demonstrated in the following code example:

XAML

<Window x:Class="Application_Docking.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 x:Name="Grid1">
          <syncfusion:DockingManager x:Name="DockingManager" UseDocumentContainer="True" ContainerMode="MDI">
              <ContentControl syncfusion:DockingManager.Header="Child1" x:Name="Content1"/>
               <ContentControl syncfusion:DockingManager.Header="Child2" x:Name="Content2" syncfusion:DockingManager.State="Document" syncfusion:DockingManager.CanClose="False"/>
               <ContentControl syncfusion:DockingManager.Header="Child3" x:Name="Content3"/>
          </syncfusion:DockingManager>
     </Grid>
</Window>

C#

using Syncfusion.Windows.Tools.Controls;
namespace Application_Docking 
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DockingManager DockingManager1 = new DockingManager();
            DockingManager1.UseDocumentContainer = true;
            DockingManager1.ContainerMode = DocumentContainerMode.MDI;
            ContentControl content1 = new ContentControl();
            DockingManager.SetHeader(content1, "Child1");
            ContentControl content2 = new ContentControl();
            DockingManager.SetHeader(content2, "Child2");
            DockingManager.SetState(content2, DockState.Document);
            DockingManager.SetCanClose(content2, false);
            ContentControl content3 = new ContentControl();
            DockingManager.SetHeader(content3, "Child3");
            DockingManager1.Children.Add(content1);
            DockingManager1.Children.Add(content2);
            DockingManager1.Children.Add(content3);
            Grid1.Children.Add(DockingManager1);         
     }
   }
}

The following screenshot shows the close button of the MDI document window is disabled.

         WPF DockingManager displays close button of MDI Window

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile