• 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的页面传值功能。

  • 相关阅读:
    截取nginx日志
    wampserver安装之后无法打开localhost
    wampserver安装之后无法打开localhost
    wampserver安装之后无法打开localhost
    wampserver安装之后无法打开localhost
    gitlab给用户添加提交到主干的权限
    动手为王 | Oracle 数据库跨版本升级迁移实践
    ie8关于@font-face无效的兼容问题
    web自定义中文字体
    django 前后台交互过程
  • 原文地址:https://www.cnblogs.com/hbhzz/p/3370223.html
Copyright © 2020-2023  润新知