在页面2中显示页面1中的注册信息

1、打开Microsoft Visual Studio 2010 Express for Windows Phone 新建2个page页面,并且布局两个页面如下图所示:

MainPage.xaml页面:

2.xaml页面:

2、添加一个DataTransferClass类:

DataTransferClass.cs类
 public class DataTransferClass
    {
        public string name { get; set; }
        public string password { get; set; }
        public string sex { set; get; }
        public string like { set; get; }
        public string city { set; get; }
    }

3、页面MainPage.xaml代码:

单击 重置 按钮
 private void button2_Click(object sender, RoutedEventArgs e)
        {
            txtName.Text = "";
            passWord.Password = "";
            checkBox1.IsChecked = false;
            checkBox2.IsChecked = false;
            checkBox3.IsChecked = false;
            checkBox4.IsChecked = false;
        }
单击 提交按钮
 private void button1_Click(object sender, RoutedEventArgs e)
        {
            //性别
            if (txtName.Text == "" || passWord.Password == "")
            {
                MessageBox.Show("请核对信息!!!");
            }
            else
            {
                string sex1 = "";
                if (radioButton2.IsChecked==true)
                {
                    sex1 = "";
                }
                //爱好
                string like1 = "";
                if (checkBox1.IsChecked == true || checkBox2.IsChecked == true || checkBox3.IsChecked == true || checkBox4.IsChecked == true)
                {
                    string a="";
                    string b="";
                    string c="";
                    string d="";
                    if (checkBox1.IsChecked == true)
                    {
                        a = " 篮球";
                    }
                    if (checkBox2.IsChecked == true)
                    {
                        b = " 爬山";
                    }
                    if (checkBox3.IsChecked == true)
                    {
                        c = " 跑步";
                    }
                    if (checkBox4.IsChecked == true)
                    {
                        d = " 游泳";
                    }
                    like1 = a + b + c + d;
                }
                else
                {
                    like1 = "";
                }
                //地址
                string sdr = "";
                ListBoxItem selectItem = listBox1.SelectedItem as ListBoxItem;
                sdr = selectItem.Content.ToString();

                App.Datatradition = new DataTransferClass
                {
                    name = txtName.Text.Trim(),
                    password = passWord.Password.Trim(),
                    sex=sex1,
                    like=like1,
                    city=sdr
                };
                this.NavigationService.Navigate(new Uri("/2.xaml", UriKind.Relative));
            }
        }

运行即可实现在页面2中显示页面1中的注册信息。

posted @ 2012-11-19 19:14  zwy_net  阅读(618)  评论(6编辑  收藏  举报