Closing Event

Feb 20, 2012 at 3:48 PM

Hi,

First, thanks for your MDI Interface, it's very usefull for my project.

I want to know , if it's possible to catch a MDI Child closing event, I want to generate an action when a MDI Child is closing but I dont't found any issue.

Can somebody help me about my problem?

Feb 11, 2014 at 1:21 PM
Hello! Used as follows:
In the constructor of my son, I put as parameter the 'Container':
MdiContainer refContainer MdiContainer = new (); 

public Child (ref MdiContainer container) {
             InitializeComponent (); 
             refContainer = container; 
         } 
  • Do not forget that Father in the window looks like this:
Son instance= new Son(ref Container);
Container.Children.Add(new MdiChild { Content = instance, Title = "Title Son" , Width = 500, Height = 500 });
In the button's click event out:
private void Close_Click (object sender, RoutedEventArgs e) 
         {
             foreach(MdiChild child in refContainer.Children.ToList())
            {
                if(((dynamic)child).Title.ToString().Contains("Title Son")) // Or '.Equals("")'
                    refContainer.Children.Remove(child);
            }
  • Note: I used the title, but you can use another way.
Hope this helps! And sorry my bad english
I'm using Google translator. kkk
Feb 11, 2014 at 1:23 PM
Hello! Used as follows:
In the constructor of my son, I put as parameter the 'Container':
MdiContainer refContainer MdiContainer = new (); 

public Child (ref MdiContainer container) {
             InitializeComponent (); 
             refContainer = container; 
         } 
  • Do not forget that Father in the window looks like this:
Son instance= new Son(ref Container);
Container.Children.Add(new MdiChild { Content = instance, Title = "Title Son" , Width = 500, Height = 500 });
In the button's click event out:
private void Close_Click (object sender, RoutedEventArgs e) 
         {
             foreach(MdiChild child in refContainer.Children.ToList())
            {
                if(((dynamic)child).Title.ToString().Contains("Title Son")) // Or '.Equals("")'
                    refContainer.Children.Remove(child);
            }
  • Note: I used the title, but you can use another way.
Hope this helps! And sorry my bad english
I'm using Google translator. kkk