Problem to open Child form from Parent form

  • Thread starter Thread starter zleug
  • Start date Start date
Z

zleug

Guest
Hi All.

I wrote code to open Child form from Parent form:

private void NewMI_Click(object sender, RoutedEventArgs e)
{
FormPt_ShowDetail(true);
}

private void FormPt_ShowDetail(bool IsNew)
{
bool isWindowOpen = false;

foreach (Window w in Application.Current.Windows)
{
if (w.GetType() == FormCh)
{
isWindowOpen = true;
w.Activate();
}
}

if (!isWindowOpen)
{
var form = new FormCh();
form.Parent = FormPt;
form.Show();
}
}
But I have problem for FormCh in line -
if (w.GetType() == FormCh)

and for form.Parent in line -

form.Parent = FormPt;

What is wrong? How to fix the problems?

Thanks.

Continue reading...
 
Back
Top