I have been trying to figure out how to switch from my MainWindow.xaml to a WPF Page in my View folder called StudentView.xaml when a button on the MainWindow is clicked.
This is what I have so far...
private void ButtonStartQuiz_Click(object sender, RoutedEventArgs e) {
var window = new View.StudentView();
}
All I want is for the MainWindow to switch to the StudentView page when the user clicks the button. I've tried opening the StudentView as a new Window, but I don't want a new window every time the user clicks a button. I've tried googling and looking at other posts, but I don't understand how I'm supposed to implement them. Please help!
After the button click then, you can create an instance of that page and set the instance as content of your mainwindow.
private NavigatingPageName Instance;
private void Button_Click(object sender, RoutedEventArgs e)
{
if (Instance == null)
{
Instance = new NavigatingPageName();
}
this.Content = Instance;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With