I currently have a Checkbox under my settings.xaml page, which the users is to click to allow location services.
private void cbLocationAllow_Checked(object sender, RoutedEventArgs e)
{
MessageBox.Show("Location Services is now enabled");
}
private void cbLocationAllow_Unchecked(object sender, RoutedEventArgs e)
{
MessageBox.Show("Location Services is now disabled");
}
I have location aware bing map on the my MainPage which I would like to have check the status of the checkbox on settings.xaml before finding location.
I assume it would a condition if else, but im not quite sure how to implement this as the checkbox is on another page.
The below code was suggested to me, but I am getting errors on
Settings.SetSetting("allowLocation",true);
On settings page:
cbLocationAllowChecked(...)
{
Settings.SetSetting("allowLocation",true);
}
cbLocationAllowUnchecked(...)
{
Settings.SetSetting("allowLocation,false);
}
On main page as conditional
MapButtonClicked(...)
{
if (!Settings.HasSetting("allowLocation") || !((bool)Settings.GetSetting("allowLocation"))
MessageBox.Show("Allow app to use your location?, "Location Services",MessageBoxButtons.OkCancel);
//handle result
else{
StartLocationSearch();
}
}
Any suggestions or links that would help me out would be great.
Thanks,
Use the
IsolatedStorageSettingsclass to save your setting.To store the setting
To read the setting