XAM-Consulting / FreshEssentials

FreshEssentials for Xamarin.Forms has ONLY the most common extensions you need for Xamarin.Forms
Apache License 2.0
107 stars 30 forks source link

Cannot default picker value #23

Closed ehmason closed 7 years ago

ehmason commented 7 years ago

Maybe I missed something but I have the BindablePicker implemented in my XAML file with SelectedItem set to a bindable property within my view model in TwoWay mode. Your example, had the list loading after a button click after the page had already loaded. I implemented my page by running the OnPropertyChange within the setter of my list used as the picker options, in the view model. So in my constructor when I set the list it loads the list before the page is shown. With this setup the list loads before the page is shown and it sets the selected correctly upon choosing an item but I can never get the picker to default via setting the selected object within the constructor of my view model before the page loads. The picker is displayed as if nothing has been selected. However, my view model has the correct value set which should be bound to the SelectedItem of the list. Is this possible?

ehmason commented 7 years ago

Issue on my side. I figured it out. The option list is object referenced so I needed to set my selected item to a reference of an object within my list after I set the list. For example //SUDO List MyList; MyObject SelectItemFromMyList; ............... MyList = GetList(); SelectedItemFromMyList = MyList.Where(SOME SEARCH).FirstOrDefault();