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
close icon

The close button doesn't work in docking manager

Hi, I added a custome user control into a scroll viewer as a new document, the container mode is MDI, when I close the document via clicking X button on right-top corner,  the event CloseButtonClick will be triggered, the event TabClosed won't be triggered. When I close the document via clicking menu item "Close", I cannot capture the CloseButtonClick and TabClosed event. What can I do to get the close event when I close the document via clicking "Close" menu item.

Another problem, I defined a user control, added it into document container, after I closed the document contains custome user control, I checked the document container, found that the count of document container's items is not reduced. Is it a bug?

I uploaded a demo for you to reproduce it, the reproduce steps:
1. Startup the pragram
2. Click menu item "Check Documents Count" in Windows menu, message box pops up
3. Close the message window
4. Click menu item "New Document"  in Windows menu, a new document will display
5. Close the new document
6. Click menu item "Check Documents Count" again
7. The count of DockingManager.DocContainer.Items is not reduced



Attachment: MDI_2b0a06ae.zip

4 Replies

NT Nick Tang June 28, 2016 02:43 AM UTC

Another problem, when I clicked "Close" menu item of a document, the event DockingManager.ContextMenuItemClick wasn't triggered.


VR Vijayalakshmi Roopkumar Syncfusion Team June 28, 2016 11:23 AM UTC

Hi Nick,

Thank you for using Syncfusion Products.

Query#: When I close the document via clicking X button on right-top corner, the event CloseButtonClick will be triggered, the event TabClosed won't be triggered. When I close the document via clicking menu item "Close", I cannot capture the CloseButtonClick and TabClosed event.

In our DockingManager, "TabClosed" event will be triggered if the closed document is in TDI mode and it will not fire for MDI document. For a MDI document, "CloseButtonClick" event of DocumentContainer will fire on clicking "Close" button and "DocumentClosing" event will fire on clicking the "Close" menu item. Code examples for subscribing these events from DocumentContainer is given below:  
(DockingManager.DocContainer as DocumentContainer).DocumentClosing += Window1_DocumentClosing; 
(DockingManager.DocContainer as DocumentContainer).CloseButtonClick += Window1_CloseButtonClick;           
 
  
Query#: Another problem, I defined a user control, added it into document container, after I closed the document contains custom user control, I checked the document container, found that the count of document container's items is not reduced. Is it a bug?  

No, it is not a bug. When we close a MDI window, it will move to hidden state and exist in the Items collection of DocumentContainer. You have to manually remove the item from DocumentContainer using CloseButtonClick event as given in below code example: 
   
void Window1_CloseButtonClick(object sender, CloseButtonEventArgs e) 
        { 
            if (DockingManager.GetHeader(e.TargetItem).ToString() == "NewItem") 
            { 
                DockingManager.DocContainer.Items.Remove(e.TargetItem); 
            } 
        } 
  
Query#: Another problem, when I clicked "Close" menu item of a document, the event DockingManager.ContextMenuItemClick wasn't triggered. 
ContextMenuItemClick event of DockingManager will be raised only for the child windows in docked and floating state. You can download the modified sample for getting close event on clicking close menu item and close button from the following link:  
Sample:MDI_Modified

Regards,
Vijayalakshmi V.R.
 



NT Nick Tang June 29, 2016 02:52 PM UTC

Great, thanks :-D


VR Vijayalakshmi Roopkumar Syncfusion Team June 30, 2016 05:07 AM UTC

Hi Nick,

Thank you for your update.

Please let us know if you need any other assistance on this.

Regards,
Vijayalakshmi V.R.

Loader.
Live Chat Icon For mobile
Up arrow icon