in my xamarin project, picker binding, the SelectedItem is not working. When I have the ItemSource set to a List, the SelectedItem works, but when I change the ItemSource to an ObservableCollection, the SelectedItem always returns null. Can someone see what I am doing wrong?
on loading the view, the pickers are populated through databinding. then on a button event I try and grab the SelectedItem.... which is when it is coming back as null.
xaml
<Picker x:Name="PickerMarket2" Title="Market2" ClassId="PickerMarket2"
ItemsSource="{Binding TestList2}"
ItemDisplayBinding="{Binding ShortDesc}"
SelectedItem="{Binding SelectedMarket}"
Grid.Row="0" Grid.Column="1" >
</Picker>
view model
class VamiMarketViewModel: INotifyPropertyChanged
{
private List<string> _testList;
public List<string> TestList
{
get { return _testList; }
set
{
{
_testList = value;
NotifyPropertyChanged();
}
}
}
private ObservableCollection<Performance> _testList2;
public ObservableCollection<Performance> TestList2
{
get { return _testList2; }
set
{
{
_testList2 = value;
NotifyPropertyChanged();
}
}
}
private string _selectedMarket;
public string SelectedMarket
{
get { return _selectedMarket; }
set
{
{
_selectedMarket = value;
NotifyPropertyChanged();
}
}
}