WPF頁面跳轉


WPF頁面跳轉:

WPF頁面跳轉有兩種:一種是windows,另外一種是page

1:windows頁面跳轉
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();


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM