Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 访问不同页面中的独立存储数据_C#_Windows Phone 8 - Fatal编程技术网

C# 访问不同页面中的独立存储数据

C# 访问不同页面中的独立存储数据,c#,windows-phone-8,C#,Windows Phone 8,我创建了一个隔离存储设置来存储播放器的数据 我在SetProfile.xaml页面中创建了它 因此,在MainPage.xaml中,有一个文本块,其中包含一个文本“Hello” 我想这样做: TextBlock1.Text=“Hello”+(播放器名称) 这就是我需要访问隔离存储的地方 我怎么能做到 SetProfile.xaml IsolatedStorageSettings Profile = IsolatedStorageSettings.ApplicationSettings; pr

我创建了一个
隔离存储设置
来存储播放器的数据
我在SetProfile.xaml页面中创建了它

因此,在MainPage.xaml中,有一个文本块,其中包含一个文本“Hello”

我想这样做:

TextBlock1.Text=“Hello”+(播放器名称)

这就是我需要访问隔离存储的地方 我怎么能做到

SetProfile.xaml

 IsolatedStorageSettings Profile = IsolatedStorageSettings.ApplicationSettings;

private void create_Click(object sender, RoutedEventArgs e)
       {
                Player player = new Player(); // Player is a class 
                player.FirstName = FirstName.Text;
                player.LastName = LastName.Text;
                player.Age = Convert.ToInt32(Age.Text);
                player.Rank = 1;
                player.RankDescreption = "Beginner";

                if (Profile.Contains("profile"))
                {
                    Profile.Remove("profile");
                    Profile.Add("profile", player);
                    Profile.Save();
                }

                else
                {
                    Profile.Add("profile", player);
                    Profile.Save();
                }

                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }


  private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
        {
           if (IsolatedStorageSettings.ApplicationSettings.Contains("profile"))
               NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
    {
        HelloName.Text = "Hello " + (WHAT I NEED) ;
    }
MainPage.xaml

 IsolatedStorageSettings Profile = IsolatedStorageSettings.ApplicationSettings;

private void create_Click(object sender, RoutedEventArgs e)
       {
                Player player = new Player(); // Player is a class 
                player.FirstName = FirstName.Text;
                player.LastName = LastName.Text;
                player.Age = Convert.ToInt32(Age.Text);
                player.Rank = 1;
                player.RankDescreption = "Beginner";

                if (Profile.Contains("profile"))
                {
                    Profile.Remove("profile");
                    Profile.Add("profile", player);
                    Profile.Save();
                }

                else
                {
                    Profile.Add("profile", player);
                    Profile.Save();
                }

                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }


  private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
        {
           if (IsolatedStorageSettings.ApplicationSettings.Contains("profile"))
               NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
    {
        HelloName.Text = "Hello " + (WHAT I NEED) ;
    }

您可以读取如下设置值:

private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
    {
    if (IsolatedStorageSettings.ApplicationSettings.Contains("profile"))
       {
         Player player =(Player)IsolatedStorageSettings.ApplicationSettings["profile"];         
        HelloName.Text ="Hello"+ player.FirstName;
       }      
    }

使用此选项肯定会对您有所帮助,但我想访问一个名为specefic的字段