minglefrog
minglefrog

Reputation: 29

"Swapping" Windows in C# WPF instead of opening a new one?

I'm trying to create a "Guide" app for a videogame. I want a button to clear everything in the window and show something else instead of creating another window. I've been using the code:

Window1 w1 = new Window1();
        w1.Show();
        this.Close();

Instead of this method, which closes the current window and opens a new one, is there a way to clear everything in the window and pop up other information?

Upvotes: 1

Views: 1359

Answers (1)

Tommehh
Tommehh

Reputation: 956

You could create a Frame in your MainWindow and display different pages.

Xaml Frame:

<Frame x:Name="MainFrame" NavigationUIVisibility="Hidden" />

After that you create a new Page-Control and navigate to it

var page = new CustomerPage();
MainFrame.Navigate(page);

Upvotes: 1

Related Questions