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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to release memory in DockingManager after closing the tab?

Remove the child from DockingManager

Closed children are moved to the “Hidden dock state so that it does not release memory. You have to manually remove the children from DockingManager in DockStateChanged event.

Remove memory held by Automation peer

DocumentContainer of DockingManager is derived from the base of Tab control. Normally TabItems Automation peer holds some memory. That memory also needs to be released by the FakeWindowAutomationPeer method as follows.

Create FakeWindowAutomationPeer class

Create a new class derived from WindowAutomationPeer class and define the override method GetChildrenCore(), and define OnCreateAutomationPeer() override method in MainWindow.

MainWindow.xaml

MainWindow.xaml.cs

public partial class MainWindow : Window

{

   public MainWindow()

   {

       InitializeComponent();

   }

//Remove child from DockingManager

   private void Docking_DockStateChanged(FrameworkElement sender, DockStateEventArgs e)

   {

       if(e.NewState==DockState.Hidden)

          Docking.Children.Remove(sender);

   }

   protected override AutomationPeer OnCreateAutomationPeer()

   {

       return new FakeWindowsPeer(this);

   }

}

public class FakeWindowsPeer : WindowAutomationPeer

{

    public FakeWindowsPeer(Window window): base(window)

    { }

    protected override List<AutomationPeer> GetChildrenCore()

    {

        return null;

    }

}

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
2735 11/20/2014 11/20/2014 WPF DockingManager
Did you find this information helpful?
Comments
Andrew Conniff Feb 08, 2016
My Issue is I am getting an error that Dockingmanager contains no definition for 'Children' am I missing an assembly reference? But I am getting Docking Manager in the code so I have ausing statement of using Syncfusion.Windows.Forms.Tools;
Reply
Not Known Feb 09, 2016
Hi Andrew, Please use the namespace as "using Syncfusion.Windows.Tools.Controls;" for WPF DockingManager control. Regards, Jessie
EloIT May 19, 2017
Hi,
I have some question. What if after closing the tab I want to decide to remove or hide window, depands of element dock state. For exemple if element is in document dock state should be remove but in other state should be hidden. At this scenario I should  create FakeWindowAutomationPeer class?

Thanks.
Reply
Marimuthu Sivalingam [Syncfusion] May 19, 2017
Hi ElolT,

Yes, if you want to remove the child from DockingManager you should add FakeWindowAutomationPeer class otherwise not necessary. 

Regards,
Marimuthu S.

Add Comment
You must log in to leave a comment

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