WPF頁面跳轉實現方法詳解
作者:佚名
WPF頁面跳轉對于初學者來說,掌握起來還是比較簡單的。主要分為前臺的WPF頁面跳轉和后天的跳轉之分。在這里為大家做一個簡要的介紹。
WPF頁面跳轉在實際程序開發中是經常會被用到的一個功能需求。在實現WPF頁面跳轉這一功能的時候,可以分為兩種情況,分別為:前臺跳轉和后臺跳轉。#t#
WPF頁面跳轉之前臺轉:
- < TextBlock FontSize="24"
TextWrapping="Wrap"
Margin="0,0,0,-19.998"> - < Hyperlink x:Name="LnkPre"
NavigateUri="Page2.xaml"
Foreground="Black"> - Enter Page2
- < /Hyperlink>
- < /TextBlock>
WPF頁面跳轉之后臺轉:
- NavigationService.GetNaviga
tionService(this).Navigate
(new Uri("Page2.xaml",
UriKind.Relative));- NavigationService.GetNavi
gationService(this).GoForward();
向后轉- NavigationService.GetNavi
gationService(this).GoBack();
向前轉- if (Application.Current.
Properties["TaskResult"]
== null) return;- bool taskResult = (bool)
Application.Current.Properties
["TaskResult"];- if (!taskResult) return;
- // If a task happened,
display task data- string taskData = (string)
Application.Current.Properties
["TaskData"];- if (taskData == null) return;
- // "End" the task be removing
state associated with- // its existence
- Application.Current.Properties
["TaskResult"] = null;- Application.Current.Properties
["TaskData"] = null;
責任編輯:曹凱
來源:
博客園