Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Showing/Hiding/Closing the Winform hosted inside a WPF WindowsFormHost?

$
0
0

So I've inherited an application that had ~10 winforms that control program flow. That program now must reside "within" a WPF application using the WindowsFormHost control. 

//MainWindow.xaml

<Grid Name="GrdMainGrid">
        <WindowsFormsHost Name="FormsHost" Margin="0,100,0,0"></WindowsFormsHost>

</Grid>

I then load the welcome form via codebehind:

//MainWindow.xaml  

      private void button2_Click(object sender, RoutedEventArgs e)
        {
            var welcomeForm = new frmWelcome();
            welcomeForm.Show();
            KioskFormHost.Child = welcomeForm;
        }

When I hit this code:

//frmWelcome.cs

button_click() {

            frmCategory form1 = new frmCategory();
            form1.Show();
            form1.Mode = "New";
            this.Close();

}

Then I lose the inside form and the other form never displays.

Is there a way to do this?



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>