WPF頁面跳轉:
WPF頁面跳轉有兩種:一種是windows,另外一種是page
windows 頁面跳轉相信學過winform編程的哥們都知道,先實例化該窗體然后show一下就可以了.eg:有兩個窗體Main和Login,要想點擊Login 窗體上的注冊按鈕然后跳轉到Main上,則在Login窗體的Click事件里代碼如下:Main Mn=new Main();Mn.Show();
2:Page頁面跳轉Page頁面跳轉:前台跳轉和后台跳轉都可以實現前台實現:
<TextBlockFontSize="24"TextWrapping="Wrap"Margin="0,0,0,0">
<Hyperlinkx:Name="LnkPre"NavigateUri="Page1.xaml"Foreground="Black">
Enter Page1
</Hyperlink>
</TextBlock>
后台實現:
NavigationService.GetNavigationService(this).Navigate(newUri("Page1.xaml", UriKind.Relative));
NavigationService.GetNavigationService(this).GoForward();//向后轉
NavigationService.GetNavigationService(this).GoBack(); //向前轉
在后台還可以這樣寫:this.content = new Page1();(這種比較簡單,但是建議大家使用前一種更能提高自己,呵呵)另外還可以以實現windows跳轉到page:
NavigationWindow window =newNavigationWindow();
window.Source =newUri("Page1.xaml", UriKind.Relative);
window.Show();