Quick Links

How to set SelectedItem in Xamarin picker when page opens

I have a small project using XamarinForms and Prism MVVM. On the settings page I save Author's ID from the Picker. When I return to the settings page I want that Author to be selected by default in the picker.

Somehow the picker does not update when you bind it with an object. From UI to code it works though.
My properties are filled correctly and the propertychanged event gets called. Still nothing shows on my label.

I did try it then with not an observablecollection but an observablecollection and it works.. It Displays the text.

I then just bound the title of the picker to SelectedAuthor.Name or what ever and it worked..

I did try it then with not an observablecollection but an observablecollection and it works.

That makes no sense. It doesn't with with an ObservableCollection but it works with an ObservableCollection. They are the same thing.

Somehow the picker does not update when you bind it with an object. From UI to code it works though.

"From UI to code it works" - no idea what you're trying to convey there. All typical binding is from UI to a property in code.

Okay my text got cut off.. Wanted to write it works with an ObservableCollection of string but not with ObservableCollection of myobject.

What I meant with the binding is that when the user makes changes on the ui it works fine. But when I try to change the value of the property it does not change the ui. This works though when I use the ObservableCollection

I know this is normal binding but somehow it does not work with a picker here.

I did try it then with not an observablecollection but an observablecollection and it works.

That makes no sense. It doesn't with with an ObservableCollection but it works with an ObservableCollection. They are the same thing.

Somehow the picker does not update when you bind it with an object. From UI to code it works though.

"From UI to code it works" - no idea what you're trying to convey there. All typical binding is from UI to a property in code.

Okay my text got cut off.. Wanted to write it works with an ObservableCollection of string but not with ObservableCollection of myobject.

What I meant with the binding is that when the user makes changes on the ui it works fine. But when I try to change the value of the property it does not change the ui. This works though when I use the ObservableCollection

I know this is normal binding but somehow it does not work with a picker here.

I'm having the same problem, can someone point me a solution?
I have this picker:<Picker StyleClass="FieldSelect" Title="Selecione uma casa" ItemsSource="{Binding Casas}" SelectedItem="{Binding Casa, Mode=TwoWay}" ItemDisplayBinding="{Binding Descricao}" />
And it works fine, but if I set the value on the ViewModel:Casa = App.conexao.Table<Models.Manutencao.Casa>().Where(i => i.Id == pedido.IdCasa).FirstOrDefault();
It just doesn't change the View, I have two pickers in this form with this issue, the other inputs work fine.