ListPicker TwoWay Binding and itemsource

494 views Asked by At

I try to build settings page to my Windows Phone 8 app, the settings page has couple of ListPickers. The basic idea has been taken from here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769510(v=vs.105).aspx

In my settings page xaml I have just declared:

<toolkit:ListPicker x:Name="listPicker1" ExpansionMode="FullScreenOnly" SelectionMode="Single" FullModeItemTemplate="{StaticResource generalListPickerFullTemplate}" ItemTemplate="{StaticResource generalListPickerTemplate}" SelectedItem="{Binding Source={StaticResource appSettings}, Path=listPicker1, Mode=TwoWay}" />

In "code behind", I create list and set it item source to 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 points to class which is basically similar than in the MS example,

public ListPickerItem listPicker1
{
    get
    {
        return GetValueOrDefault<ListPickerItem>(KeyName, Default);
    }

    set
    {
        if (AddOrUpdateValue(KeyName, value))
        {
            Save();
        }
    }
}

So is it not possible to set itemsource and use two way bindig? If I set these both, I get System.ArgumentOutOfRangeException.

Basically my only goal is to have listPicker with items, which have text to display for user and value. And to easily set and get these to Isolates storage.

1

There are 1 answers

1
MatDev8 On

You have this error when you set itemsource or select an item?