在wpf中从一个页面跳转到另外一个一面,使用导航,比如从page1跳转到page2,代码如下:
1 private void button9_Click(object sender, RoutedEventArgs e)
2 {
3 Page2 page2 = new Page2();
4 this.NavigationService.Navigate(page2);
5 }
在新建了一个项目后,默认的起始页是从新建的第一个页面开始,当然可以更改为任意的页面作为起始页,打开App.xmal,代码如下:
1 <Application x:Class="StackPanel.App"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 StartupUri="Page1.xaml">
5 <Application.Resources>
6
7 </Application.Resources>
8 </Application>
其中StartupUri="Page1.xaml",把名字改成需要的就OK!