Articles in this section
Category / Section

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

1 min read

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

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