diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38723.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38723.cs index 2defadec1..10db986f3 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38723.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38723.cs @@ -1,5 +1,4 @@ -using System; -using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.CustomAttributes; using Xamarin.Forms.Internals; #if UITEST @@ -7,52 +6,60 @@ using Xamarin.UITest; using NUnit.Framework; #endif -namespace Xamarin.Forms.Controls +namespace Xamarin.Forms.Controls.Issues { [Preserve(AllMembers = true)] - [Issue(IssueTracker.Bugzilla, 38723, "Update Content in Picker's SelectedIndexChanged event causes NullReferenceException", PlatformAffected.iOS)] - public class Bugzilla38723 : TestContentPage // or TestMasterDetailPage, etc ... + [Issue(IssueTracker.Bugzilla, 38723, "Update Content in Picker's SelectedIndexChanged event causes NullReferenceException", PlatformAffected.All)] + public class Bugzilla38723 : TestContentPage { - Picker _datePicker; - Label _dateLabel; - protected override void Init() { - _datePicker = new Picker + var label = new Label { - //HorizontalOptions = LayoutOptions.FillAndExpand, - VerticalOptions = LayoutOptions.Center, - Title = "Pick a Date", - }; - _datePicker.SelectedIndexChanged += DatePickerSelected; - - for (var i = 0; i < 7; i++) - { - _datePicker.Items.Add(DateTime.Now.AddDays(i).ToString("dd, MMM, yyyy(dddd)")); - } - - var stackLayout = new StackLayout - { - Padding = new Thickness(10, 10) + Text = "NoSelected" }; - _dateLabel = new Label + var picker = new Picker { - HorizontalOptions = LayoutOptions.StartAndExpand, - VerticalOptions = LayoutOptions.Center, - Text = "Placeholder" + Title = "Options", + ItemsSource = new[] { "option1", "option2", "option3" } }; - stackLayout.Children.Add(_datePicker); - stackLayout.Children.Add(_dateLabel); - // Update current page's UI would cause NullReferenceException - Content = stackLayout; + picker.SelectedIndexChanged += (sender, args) => + { + label.Text = "Selected"; + Content = label; + }; + + var button = new Button + { + Text = "SELECT" + }; + + button.Clicked += (sender, args) => + { + picker.SelectedIndex = 0; + }; + + Content = new StackLayout + { + Children = + { + label, + picker, + button + } + }; } - void DatePickerSelected(object sender, EventArgs args) +#if UITEST + [Test] + public void Bugzilla38723Test() { - _dateLabel.Text = args.ToString(); - Content = _dateLabel; + RunningApp.Tap(q => q.Marked("SELECT")); + RunningApp.WaitForElement(q => q.Marked("Selected")); + RunningApp.WaitForNoElement(q => q.Marked("SELECT")); } +#endif } -} \ No newline at end of file +}