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.

The close button doesn't work in docking manager

Thread ID:

Created:

Updated:

Platform:

Replies:

124742 Jun 27,2016 05:30 AM Jun 30,2016 01:07 AM WPF 4
loading
Tags: DockingManager
Nick Tang
Asked On June 27, 2016 05:30 AM

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

Nick Tang
Replied On June 27, 2016 10:43 PM

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

Vijayalakshmi Roopkumar [Syncfusion]
Replied On June 28, 2016 07:23 AM

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.
 


Nick Tang
Replied On June 29, 2016 10:52 AM

Great, thanks :-D

Vijayalakshmi Roopkumar [Syncfusion]
Replied On June 30, 2016 01:07 AM

Hi Nick,

Thank you for your update.

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

Regards,
Vijayalakshmi V.R.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;