第一个界面代码
private void button1_Click(object sender, RoutedEventArgs e)
{
//界面跳转并且传参
string mylogin = "/Index.xaml?name=13816769764&pwd=123";
this.NavigationService.Navigate(new Uri(mylogin, UriKind.Relative));
}
接收界面代码
public partial class Page1 : PhoneApplicationPage
{
public Page1()
{
InitializeComponent();
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
//获取MainPage.xaml传过来的参数(添加当前方法,必须在index.xaml里添加Loaded="PhoneApplicationPage_Loaded"属性)
if (this.NavigationContext.QueryString.ContainsKey("name"))
{
string name = this.NavigationContext.QueryString["name"];
//UI控件赋值
textBox_name.Text = name;
//打印日志(后台输出日志:点击顶部debug--windows--output就行)
Debug.WriteLine("打印用户名:" + name);
}
if (this.NavigationContext.QueryString.ContainsKey("pwd"))
{
string pwd = this.NavigationContext.QueryString["pwd"];
textBox_pwd.Text = pwd;
Debug.WriteLine("打印密码:" + pwd);
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.GoBack();
}
}
如果还是看不懂的,去我的资源里下载代码