Windows phone 7 在何处访问隔离存储值?
默认情况下,调用checked方法。如果用户取消选中按钮,则登录应用程序的用户需要再次显示未选中的,因为该用户以前未选中btn。但它是show checked。为此,我将在独立存储中保存一个值。Windows phone 7 在何处访问隔离存储值?,windows-phone-7,isolatedstorage,Windows Phone 7,Isolatedstorage,默认情况下,调用checked方法。如果用户取消选中按钮,则登录应用程序的用户需要再次显示未选中的,因为该用户以前未选中btn。但它是show checked。为此,我将在独立存储中保存一个值。 您能告诉我从何处访问隔离变量值吗?您似乎没有调用ApplicationSettings对象上的Save方法。 请阅读如何使用独立存储 要保存设置,请执行以下操作: this.toggle.Content = "Visibity is off"; this.
您能告诉我从何处访问隔离变量值吗?您似乎没有调用ApplicationSettings对象上的
Save
方法。请阅读如何使用独立存储 要保存设置,请执行以下操作:
this.toggle.Content = "Visibity is off";
this.toggle.SwitchForeground = new SolidColorBrush(Colors.Red);
appSettings.Add("value", "off");
}
void toggle_Checked(object sender, RoutedEventArgs e)
{
this.toggle.Content = "Visibity is on";
this.toggle.SwitchForeground = new SolidColorBrush(Colors.Green);
appSettings.Add("value", "on");
}
void toggle_Indeterminate(object sender, RoutedEventArgs e)
{
//add some content here
}
void toggle_Click(object sender, RoutedEventArgs e)
{
//add some content here
}
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
if (!settings.Contains("userData"))
{
settings.Add("userData", "some value");
}
else
{
settings["userData"] = "some value";
}
settings.Save();
要检索设置,请执行以下操作:
this.toggle.Content = "Visibity is off";
this.toggle.SwitchForeground = new SolidColorBrush(Colors.Red);
appSettings.Add("value", "off");
}
void toggle_Checked(object sender, RoutedEventArgs e)
{
this.toggle.Content = "Visibity is on";
this.toggle.SwitchForeground = new SolidColorBrush(Colors.Green);
appSettings.Add("value", "on");
}
void toggle_Indeterminate(object sender, RoutedEventArgs e)
{
//add some content here
}
void toggle_Click(object sender, RoutedEventArgs e)
{
//add some content here
}
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
if (!settings.Contains("userData"))
{
settings.Add("userData", "some value");
}
else
{
settings["userData"] = "some value";
}
settings.Save();
因此,在您的情况下,在Checked&UnChecked事件中保存复选框的状态,并在页面的init中加载状态。您可以在任何页面中访问isolatedstorage值,方法与创建该值相同 尝试在InitializeComponent()之后访问Settings()构造函数中的值 然后,您可以根据“值”更改切换按钮的值
public Settings()
{
InitializeComponent();
string value;
if (appSettings.Contains("value"))
{
appSettings.TryGetValue("value", out value);
}