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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to release memory in DockingManager after closing the tab?

Platform: WPF |
Control: DockingManager |
Published Date: November 20, 2014 |
Last Revised Date: November 20, 2014

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;

    }

}

 

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
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.

Please sign in to access our KB

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

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