Bug 60846 - Picker Itemsource of IEnumerable<Real object> not working
Summary: Picker Itemsource of IEnumerable<Real object> not working
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.5.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-11-24 09:03 UTC by Joacim Wall
Modified: 2017-11-29 07:50 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 60846 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Joacim Wall 2017-11-24 09:03:23 UTC
Hi Xamarin picker crash on SelectedItemChange event. 

This happened only for realm objects I filed a report on the realm forum but the think it's in the control. 

Please se this.


Code to reproduce it.

Comment 1 Paul DiPietro [MSFT] 2017-11-28 22:43:16 UTC
I'm reading the comments in the first link's discussion and it looks as if your issue has been resolved. Can you confirm?
Comment 2 Joacim Wall 2017-11-29 07:44:14 UTC
it's has not been resolved there are A workaround. The Picker has more flows.

Fill a Picker with object with id and name throw viewmodel and observibleCollection using itemsource and selecteditem.

1. Select one of them 
2. Navigate to new page and edit name off the object in the picker thow 
   binded entry.
   Navigation.PushAsync(new Views.Phone.CustomerPage(new 
3. Edit Name of the selected object
4. Save and Navigation.PopAsync(true);
5. I see that the SelectedCustomer is updated but not the picker.
when you get back to the previous page the picker is not updated but the selectedCustomer is.If you change the picker to i listview it works.  

My workaround for this is in the codebehind of the firstpage in 
protected override void OnAppearing() .. 
(BindingContext as ViewModels.StartPageViewModel).InitPickers();

public async void InitPickers()
string selectedCustomerId = null;
if (SelectedCustomer != null)
selectedCustomerId = SelectedCustomer.CustomerId;
Customers = CustomerRepository.GetAllCustomers();
await System.Threading.Tasks.Task.Delay(250);
SelectedCustomer = Customers.FirstOrDefault(x => x.CustomerId == selectedCustomerId);
else /
Customers = CustomerRepository.GetAllCustomers();

The solution is await line, thinks it's need to load gui before i can set selected item. The strange thing is if i replace picker with a listview it works out of the box on PopAsync.
Comment 3 Joacim Wall 2017-11-29 07:50:37 UTC
For your info i use net standard 2.0 and problem is on Iphone 8 IOS 11.1 simulator.