I have a page in a Windows Phone 7 app where the user can edit or delete an Transaction object. The Transaction object is an Linq-to-Sql class that have a relationship with
ListPicker uses Items.IndexOf to get the index of item instance that it should select.
If the instance does not match (it is not an object instance from the collection) the IndexOf will return -1 and the InvalidOperationException is thrown with the message: "SelectedItem must always be set to a valid value".
Override Equals method of the item type in the collection and it will work as expected.
Example:
public override bool Equals(object obj)
{
var target = obj as ThisType;
if (target == null)
return false;
if (this.ID == target.ID)
return true;
return false;
}
Hope it helps