WPF頁面跳轉(zhuǎn)實現(xiàn)方法詳解
作者:佚名
WPF頁面跳轉(zhuǎn)對于初學(xué)者來說,掌握起來還是比較簡單的。主要分為前臺的WPF頁面跳轉(zhuǎn)和后天的跳轉(zhuǎn)之分。在這里為大家做一個簡要的介紹。
WPF頁面跳轉(zhuǎn)在實際程序開發(fā)中是經(jīng)常會被用到的一個功能需求。在實現(xiàn)WPF頁面跳轉(zhuǎn)這一功能的時候,可以分為兩種情況,分別為:前臺跳轉(zhuǎn)和后臺跳轉(zhuǎn)。#t#
WPF頁面跳轉(zhuǎn)之前臺轉(zhuǎn):
- < 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頁面跳轉(zhuǎn)之后臺轉(zhuǎn):
- NavigationService.GetNaviga
tionService(this).Navigate
(new Uri("Page2.xaml",
UriKind.Relative));- NavigationService.GetNavi
gationService(this).GoForward();
向后轉(zhuǎn)- NavigationService.GetNavi
gationService(this).GoBack();
向前轉(zhuǎn)- 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;
責(zé)任編輯:曹凱
來源:
博客園