您的位置:首页 > 其它

02-实现页面的跳转的功能

2013-09-11 00:44 344 查看
1.主要的知识点:

NavigationService.navigate方法

实现步骤:

1.拖动添加工具箱中的button按钮到手机界面上,点中button按钮,右边的button标签背景色变为灰色,修改Content值为页面跳转



2.双击页面跳转按钮,进入代码编辑区

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace changePage
{
public partial class MainPage : PhoneApplicationPage
{
// 构造函数
public MainPage()
{
InitializeComponent();
}
//点击页面跳转按钮触发的方法,跳转到Welcome.xaml页面
private void button1_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Welcome.xaml", UriKind.Relative));
}
//页面跳转时触发的方法,让用户决定是否跳转页面
protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
{
base.OnNavigatingFrom(e);
if (MessageBox.Show("确定要跳到下个页面吗?", "警告提示", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
{
e.Cancel = true;
}
}
}
}

3.创建跳转后的页面



4.新建页面



5.添加一个TextBlock,同样的修改里面的值



6.点击运行



运行效果:





内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐