简体   繁体   中英

How do I navigate back to the main window in WPF?

I have a MainWindow.xaml which opens up bugsSplat.xaml in a frame.

In MainWindow.xaml, I have a code that looks like

<Frame Grid.Row ="1"  x:Name="_mainFrame" NavigationUIVisibility="Hidden"/>

In the MainWindow.xaml.cs,

scorePlayer.Play();
RightHand.Visibility = Visibility.Collapsed;
mainMenuButtons.Visibility = Visibility.Collapsed;
(Application.Current.MainWindow.FindName("_mainFrame") as Frame).Source = new Uri("BugsSplat.xaml", UriKind.Relative);

What it does is that it plays a sound, hides the rightHand cursor and main menu buttons from the MainWindow and load BugsSplat.xaml into _mainFrame

My question is, how do I "hide" all new contents loaded from bugSplat.xaml and "unhide" the RightHand and mainMenuButtons so It will look like when you just started the application.

它为您工作以下代码吗?

(Application.Current.MainWindow.FindName("_mainFrame") as Frame).Source = null;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM