zoukankan      html  css  js  c++  java
  • silverlight中实现页面传值


       
       该实例中使用独立存储的IsolatedStorageSettings 对象进行页面之间的传值

        将文本框txtName的值由MainPage.xaml页面传到Main.xaml页面。

       (1)使用该对象前,要在cs页面调用命名空间:System.IO.IsolatedStorage
       (2)MainPage.xaml:
         //定义独立的存储对象
            private IsolatedStorageSettings appSetting = IsolatedStorageSettings.ApplicationSettings;
            private void button1_Click(object sender, RoutedEventArgs e)
            {
                if (txtName.Text != null && txtPwd.Text != null)
                {
                    if (txtName.Text == "rainie" && txtPwd.Text == "123")
                    {
                        //页面传值
                        if (!appSetting.Contains("name"))
                        {
                            appSetting.Add("name", txtName.Text.Trim());
                        }
                  else
                  {
                   appSetting.Clear();
                   appSetting.Add("name",txtName.Text.Trim());
                }

                        App.Navigation(new Main());
                    }
                }
            }

        (3)Main.xaml接收值:
         //申明变量
            private IsolatedStorageSettings appSetting = IsolatedStorageSettings.ApplicationSettings;
            private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
            {
                if (appSetting.Contains("name"))
                {
                    tbName.Text = appSetting["name"].ToString();
                }
            }

        
        这样就实现了silverlight的页面传值功能。

  • 相关阅读:
    Ubuntu 12.04下GAMIT10.40安装说明
    GAMIT 10.50在Ubuntu 12.04系统下的安装
    tomcat 5.5 动态加载类
    GAMIT 10.50在Ubuntu 12.04系统下的安装
    RHCE 系列(九):如何使用无客户端配置 Postfix
    Nginx+Keepalived(带Nginx监控脚本)
    黑马程序员_java08_多线程
    oracle 表类型变量的使用
    如何在win7系统中安装redis
    bzoj 2816: [ZJOI2012]网络(splay)
  • 原文地址:https://www.cnblogs.com/hbhzz/p/3370223.html
Copyright © 2011-2022 走看看