Answer the question
In order to leave comments, you need to log in
Why doesn't redirect to another window work in WPF?
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (seven.IsChecked == true)
{
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new Uri("/SevenCalss.xaml", UriKind.Relative));
}
if (eight.IsChecked == true)
{
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new Uri("/EightClass.xaml", UriKind.Relative));
}
if (nine.IsChecked == true)
{
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new Uri("/NineCalss.xaml", UriKind.Relative));
}
}
}
}
Answer the question
In order to leave comments, you need to log in
See a working example implementation here:
How to navigate between pages in Windows Presentation Foundation?
You just have a window open and the service is called in it. This does not mean that MainWindow will close and a new window will open. You need to use either Frame or NavigationWindow (help supports Russian, change en-us to ru-ru).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question