我尝试在我的Windows phone8应用程序中构建设置页面,该设置页面有几个ListPickers。基本思想取自于此:http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769510(v=vs.105).aspx
在我的设置页面xaml中,我刚刚声明:
<toolkit:ListPicker x:Name="listPicker1" ExpansionMode="FullScreenOnly" SelectionMode="Single" FullModeItemTemplate="{StaticResource generalListPickerFullTemplate}" ItemTemplate="{StaticResource generalListPickerTemplate}" SelectedItem="{Binding Source={StaticResource appSettings}, Path=listPicker1, Mode=TwoWay}" />在“代码隐藏”中,我创建了list并将它的项源设置为listPicker1
listPicker1List.Add(new ListPickerItem() { name = "First value", value = "value_1" });
listPicker1List.Add(new ListPickerItem() { name = "Second value", value = "value_2" });
this.listPicker1.ItemsSource = listPicker1List;StaticResource appSettings指向的类与MS示例中的类基本相似,
public ListPickerItem listPicker1
{
get
{
return GetValueOrDefault<ListPickerItem>(KeyName, Default);
}
set
{
if (AddOrUpdateValue(KeyName, value))
{
Save();
}
}
}所以设置itemsource和使用双向bindig是不可能的吗?如果我将这两个都设置,我会得到System.ArgumentOutOfRangeException。
基本上,我唯一的目标是拥有带有项目的listPicker,它有文本可供用户和值显示。并且可以轻松地将这些设置和获取到隔离存储。
发布于 2013-08-29 19:59:25
在设置项目来源或选择项目时出现此错误?
https://stackoverflow.com/questions/18493365
复制相似问题