I have create child window using the user control and add the child window on main mdi window through menu.
i want to close the child window through a button. please tell me how we can close the child window.
thank you in advance
How to close child window create through user control?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Pavan RamamurthyRank #1,682 · 906 reputationPosted Sep 13, 2013, 9:24 PM EDT
//to close user control
private void button1_Click(object sender, RoutedEventArgs e)
{
if (this.ParentControl != null)
this.ParentControl.Children.Remove(this);
}
Kiran Kumar TalikotiRank #814 · 2.8K reputationPosted Sep 13, 2013, 9:44 PM EDT
Hi Baljindra,
try this code in close button,here i have used user control in Grid.Whatever layout you used replace in underlined word
private void Close_Button( object sender, RoutedEventArgs e )
{
(this.Parent as Grid).Children.Remove(this);
}