There is a MainWindow,a usercontrol which is located in my MainWindow and a OtherForm which i am going to show from usercontrol. I sent OtherForm as parameter from MainWindow to usercontrol.And in usercontrol i am calling OtherForm.showdialog.When i show it second time ,i am getting "Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed" problem.
Codes: in MainWindow class
void Example()
{
usercontrol.Load(new Otherform{ variable= 1 });
}
In Usercontrol class
private Window _form;
public void Load(window form)
{
_form=form;
}
void ExampleInUSerControl
{
_form.VerifyAccess();
_form.Activate();
_form.ShowActivated = true;
_form.ShowDialog();
}