Bug 38723 - Update Content in Picker's SelectedIndexChanged event causes NullReferenceException
Summary: Update Content in Picker's SelectedIndexChanged event causes NullReferenceExc...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.0.0
Hardware: PC Windows
: Normal major
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-02-12 18:13 UTC by Jun Zhang
Modified: 2017-03-22 19:46 UTC (History)
9 users (show)

See Also:
Tags: ac
Is this bug a regression?: ---
Last known good build:


Description Jun Zhang 2016-02-12 18:13:47 UTC
var datePicker = new Picker() {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.Center,
                Title = "Pick a Date",
datePicker.SelectedIndexChanged += DatePickerSelected;

void DatePickerSelected(object sender, EventArgs args) {
            dateLabel.Text = "New Date";
            // Updating current page's UI will cause NullReferenceException
            Content = dateLabel;

You can't update Page.Content inside Picker's SelectedIndexChanged event.
Comment 1 Jun Zhang 2016-02-12 18:27:57 UTC
I created a sample project for this bug, which is in link below:
Comment 2 adrianknight89 2016-10-31 16:27:37 UTC
See https://github.com/xamarin/Xamarin.Forms/pull/494
Comment 3 Samantha Houts [MSFT] 2016-12-30 18:37:09 UTC
Should be fixed in 2.3.4-pre2. Thanks!
Comment 4 Parmendra Kumar 2017-02-01 17:57:28 UTC
I have checked this issue with Xamarin.Forms and observed that this issue still exist.

Screencast: https://www.screencast.com/t/tbGnZox1i

OutputLog: https://gist.github.com/Parmendrak/da41384fd9430fbbc1402c9d63070187

Hence reopening this issue.
Comment 5 Rui Marinho 2017-03-22 19:19:49 UTC
Comment 6 Rui Marinho 2017-03-22 19:46:03 UTC
Should be fixed on 2.3.4-pre6

Note You need to log in before you can comment on or make changes to this bug.