Setting selected item on Listbox in Silverlight - Windows Phone 7
- by Fishcake
I have a databound Listbox bound to a generic list as follows (Provider is a very simple class that just includes a single property (Name).
ProviderList = new List<Provider>();
//Populate list
Providers.ItemsSource = ProviderList;
I can save the selected item with no problem but I can't manage to set the selected item from code afterwards. I am trying to do so as follows:
int x = Providers.Items.IndexOf((Provider)_Settings["provider"]);
However IndexOf() is always returning -1. If I inspect both Providers.Items[1] and _Setting["provider"] at runtime using the immediate window they both return
{StoreRetrieveData.Provider}
Name: "Greenflag"
Am I doing something wrong (well clearly I am)?