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的字段