none
IsolatedStorageSettings的问题 RRS feed

答案

  • 您好,

    您是不是没有把数据保存成功啊. 请在OnNavigateFrom方法里保存数据到IsolatedStorageSettings中. 然后再OnNavigateTo方法里去获取存在IsolatedStorageSettings里的数据。

    Happy New Year.

    ---Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年2月20日 6:27
    版主

全部回复

  • 你是不是没有发布好啊。不应该啊。

    Vote if help you

    2015年2月16日 11:04
  • 您好,

    您是不是没有把数据保存成功啊. 请在OnNavigateFrom方法里保存数据到IsolatedStorageSettings中. 然后再OnNavigateTo方法里去获取存在IsolatedStorageSettings里的数据。

    Happy New Year.

    ---Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年2月20日 6:27
    版主
  • 您帮我看看 这样保存是不是没有问题呢?拜托了!

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using Microsoft.Phone.Controls;
    using Microsoft.Phone.Shell;
    using System.Windows.Media.Imaging;
    using cn.bmob.api;
    using System.IO.IsolatedStorage;
    using WonderSound.Vo;
    using cn.bmob.io;
    
    namespace WonderSound
    {
        public partial class LoginPage : PhoneApplicationPage
        {
            private BmobWindowsPhone _Bmob = new BmobWindowsPhone();
            private IsolatedStorageSettings userInfo = IsolatedStorageSettings.ApplicationSettings;
            public LoginPage()
            {
                InitializeComponent();
            }
    
            private void Login_Loaded(object sender, RoutedEventArgs e)
            {
                this.LoginBackground.ImageSource = new BitmapImage(new Uri("" + userInfo["_background"], UriKind.Absolute));
            }
    
            //登录
            private void Login_Click(object sender, EventArgs e)
            {
                if (this.username.Text != "" && this.username.Text != null && this.password.Password != "" && this.password.Password != null)
                {
                    this.LoginProgressBar.Visibility = Visibility.Visible;
                    _Bmob.Login<WonderSoundUser>(this.username.Text, password.Password, (resp, exception) =>
                    {
                        if (exception != null)
                        {
                            Dispatcher.BeginInvoke(() =>
                            {
                                this.LoginProgressBar.Visibility = Visibility.Collapsed;
                                MessageBox.Show("登录失败,请重试");
                            });
                            return;
                        }
                        Dispatcher.BeginInvoke(() =>
                        {
                            //定义需要存储的键/值对
                            WonderSoundUser user = BmobUser.CurrentUser as WonderSoundUser;
                            //如果判断是否已经存在,存在修改,不存在添加
                            if (userInfo.Contains("username"))
                            {
                                userInfo["username"] = user.username;
                            }
                            else
                            {
                                userInfo.Add("username", user.username);
                            }
    
                            if (user.ico == null)
                            {
                                if (userInfo.Contains("userico"))
                                {
                                    userInfo["userico"] = "http://file.bmob.cn/M00/AC/95/oYYBAFTsTQmAFwDbAAA5t0T5cw0386.png";
                                }
                                else
                                {
                                    userInfo.Add("userico", "http://file.bmob.cn/M00/AC/95/oYYBAFTsTQmAFwDbAAA5t0T5cw0386.png");
                                }
                            }
                            else
                            {
                                if (userInfo.Contains("userico"))
                                {
                                    userInfo["userico"] = user.ico.getPath();
                                }
                                else
                                {
                                    userInfo.Add("userico", user.ico.getPath());
                                }
    
                            }
                            //如果判断是否已经存在,存在修改,不存在添加
                            if (userInfo.Contains("userobjectId"))
                            {
                                userInfo["userobjectId"] = user.objectId;
                            }
                            else
                            {
                                userInfo.Add("userobjectId", user.objectId);
                            }
                            //如果判断是否已经存在,存在修改,不存在添加
                            if (userInfo.Contains("sessionToken"))
                            {
                                userInfo["sessionToken"] = user.sessionToken;
                            }
                            else
                            {
                                userInfo.Add("sessionToken", user.sessionToken);
                            }
                            //保存信息,如果不调用的话,重启后数据会丢失
                            userInfo.Save();
                            this.LoginProgressBar.Visibility = Visibility.Collapsed;
                            NavigationService.GoBack();
                        });
                    });
                }
                else
                {
                    Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show("亲!你忘记填写密码或账号了");
                    });
                }
            }
    
            //注册
            private void Add_Click(object sender, EventArgs e)
            {
                NavigationService.Navigate(new Uri("/RegisterPage.xaml", UriKind.Relative));
            }
        }
    }

    2015年3月9日 11:09
  • 这是取的代码 在主页面的OnNavigatedTo方法里面取

     protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                try
                {
                    username = "" + userInfo["username"];
                    if (username != null && username != "")
                    {
                        ((ApplicationBarMenuItem)this.ApplicationBar.MenuItems[0]).Text = username;
                        this.User.Title = username;
                        this.User.Message = "亲爱的" + username + "希望WonderSound能给你带来快乐:)";
                        this.User.Source = new BitmapImage(new Uri("" + userInfo["userico"], UriKind.Absolute));
                    }
                   
                }
                catch (Exception ee)
                {
    
                }
    }

    2015年3月9日 11:11