winphone 开发学习笔记(2)

导航

NavigationService.Navigate(new Uri("xxxx.xaml",UriKind.Relative))

xxx表示要跳转的目标页面

页面和页面导航相关的虚方法

1.OnNavigatedTo:当页面成为活动页面时调用 2.OnNavigateFrom:当页面不再是活动页面时调用 3.OnNavigatingFrom:当页面即将不再是活动额面时调用,可以用e.Cancel=true; 4.OnBackKeyPress:当用户按下手机上的后退键时候调用,可以在事件e.Cancel=true

取消后 退执行自己的处理逻辑(比如:退出系统)

eg:

protected override void OnNavigatedTo(NavigationEventArgs e)

{

base.OnNavigatedTo(e);

MessageBox.Show(”当前页面"):

}

 页面传值

eg:

 

NavigationService.Navigate(new Uri("xxx.xaml?name=tom",UriKind.Relative))



protected override void OnNavigatedTo(NavigationEventArgs e)

{

base.OnNavigatedTo(e);

//判断name的key存在的时候才往下取

if(NavigationContext.QueryString.ContainsKey("name"))

string name=NavigationContext.QueryString["name"];

TextBlock.Text=name;//显示在textblock上

继续努力

 

 

 

 

你可能感兴趣的:(学习笔记)