Reputation: 1191
I have a page in Windows Phone, where the user has to chose one value (a string) in a ComboBox item. After he presses the button, this value should be stored in the settings preference. How can I do this? Also, this value should be read in other page/class in the Windows Phone 8.1 application. I tried this code, but it doesn't work:
private void save(object sender, RoutedEventArgs e)
{
var applicationData = Windows.Storage.ApplicationData.Current;
var roamingSettings = applicationData.RoamingSettings;
// Create a simple setting
roamingSettings.Values["surname"] = surnamesBox.SelectedItem;
}
Upvotes: 0
Views: 337
Reputation: 1414
The problem is that you try to save the SelectedItem object itself. Convert it to a string:
roamingSettings.Values["surname"] = surnamesBox.SelectedItem.ToString();
Upvotes: 2