Windows phone 8 如何在列表选择器中设置selectedIndex,在windows phone 8中检索用于隔离存储设置的列表选择器
我正在开发一个windows phone 8应用程序,其中我必须使用listPicker控件。我需要将selectedIndex从listPicker中的选定项保存到isolatedStorageSettings中,以便在应用程序打开时使用它。当应用程序再次运行时,我希望保存的索引成为listPicker中的选定索引。在我拥有控件的页面中,我尝试使用onnavigatedto和onnavigatedfrom方法来实现这一点。问题是,当我更改se所选项目并从完全模式返回时,所选项目不会更改。我又查了一遍这个问题,还没有找到解决办法。我怎样才能解决它Windows phone 8 如何在列表选择器中设置selectedIndex,在windows phone 8中检索用于隔离存储设置的列表选择器,windows-phone-8,isolatedstorage,listpicker,Windows Phone 8,Isolatedstorage,Listpicker,我正在开发一个windows phone 8应用程序,其中我必须使用listPicker控件。我需要将selectedIndex从listPicker中的选定项保存到isolatedStorageSettings中,以便在应用程序打开时使用它。当应用程序再次运行时,我希望保存的索引成为listPicker中的选定索引。在我拥有控件的页面中,我尝试使用onnavigatedto和onnavigatedfrom方法来实现这一点。问题是,当我更改se所选项目并从完全模式返回时,所选项目不会更改。我又查
对不起,我的英语不好我按照这个设置示例修改了列表框示例,以进行常规设置。我在尝试使用具有这样的隔离存储的ListPicker时遇到了几个问题。 我删除了ListPicker的数据绑定,在初始化后设置SelectedIndex,并将SelectedIndex存储在SelectionChanged上的独立存储中,该存储在首次加载页面后更改。这是一个迂回的解决方案,但我的搜索结果是空的
public List<string> daysOfWeek = new List<string>() { "Sunday", "Monday", "etc" };
public int listPickerCounter = 0;
public Settings()
{
InitializeComponent();
BuildLocalizedApplicationBar();
// Fill listPicker with string items
this.listPicker.ItemsSource = daysOfWeek;
// Set SelectedIndex = IsolatedStorage Variable
if (IsolatedStorageSettings.ApplicationSettings.Contains("ListPickerSetting"))
{
this.listPicker.SelectedIndex = (int)IsolatedStorageSettings.ApplicationSettings["ListPickerSetting"];
}
}
编辑:忘记添加另一个真正有助于理解独立存储的引用。
private void listPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (listPickerCounter > 0 && IsolatedStorageSettings.ApplicationSettings.Contains("ListPickerSetting"))
{
IsolatedStorageSettings.ApplicationSettings["ListPickerSetting"] = (int)this.listPicker.SelectedIndex;
}
listPickerCounter++;
}