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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kiran Kumar TalikotiPosted Sep 14, 2013, 1:44 AM
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);
}
Pavan RamamurthyPosted Sep 14, 2013, 1:24 AM
//to close user control
private void button1_Click(object sender, RoutedEventArgs e)
{
if (this.ParentControl != null)
this.ParentControl.Children.Remove(this);
}