summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32847.cs
blob: 7014cf355bdd8e8e4d1345a4d04672d2c748cd5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.Collections.Generic;
using Xamarin.Forms.CustomAttributes;

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 32847,
		"Picker text is cleared after selecting an item, whether Picker, DatePicker, or TimePicker (when in a TableView (or ListView))", PlatformAffected.WinRT)]
	public class Bugzilla32847 : TestContentPage
	{
		protected override void Init ()
		{
			var instructions =
				@"In the picker below, select the option labeled 'Two'. If the selection immediately disappears, the test has failed.
In the TimePicker below, change the time to 5:21 PM. If the selection immediately disappears, the test has failed.
In the DatePicker below, change the date to May 25, 1977. If the selection immediately disappears, the test has failed.";

			var tableInstructions = new Label {
				Text = instructions
			};

			var picker = new Picker ();

			var pickerItems = new List<string> { "One", "Two", "Three" };

			foreach(string item in pickerItems)
			{
				picker.Items.Add(item);
			}

			var datePicker = new DatePicker ();
			var timePicker = new TimePicker ();

			var tableView = new TableView() { BackgroundColor = Color.Green };

			var tableSection = new TableSection();

			var pickerCell = new ViewCell { View = picker };
			var datepickerCell = new ViewCell { View = datePicker };
			var timepickerCell = new ViewCell { View = timePicker };

			tableSection.Add(pickerCell);
			tableSection.Add(timepickerCell);
			tableSection.Add(datepickerCell);

			var tableRoot = new TableRoot() {
				tableSection
			};

			tableView.Root = tableRoot;

			var listItems = new List<string> { "One" };

			var listView = new ListView
			{
				Header = instructions,
				BackgroundColor = Color.Pink,
				ItemTemplate = new DataTemplate(typeof(CustomCell)),
				ItemsSource = listItems
			};

			var nonListDatePicker = new DatePicker();
			var nonListTimePicker = new TimePicker();
			var nonListPicker = new Picker();

			foreach(string item in pickerItems)
			{
				nonListPicker.Items.Add(item);
			}

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Fill,
				HorizontalOptions = LayoutOptions.Fill,
				Children = {
					new Label { Text = instructions },
					nonListPicker, 
					nonListDatePicker,
					nonListTimePicker,
					tableInstructions,
					tableView,
					listView
				}
			};
		}
	}

	[Preserve (AllMembers = true)]
	public class CustomCell : ViewCell
	{
		public CustomCell()
		{
			StackLayout cellWrapper = new StackLayout();
			StackLayout stack = new StackLayout();

			var picker = new Picker();
			var datePicker = new DatePicker ();
			var timePicker = new TimePicker ();

			var items = new List<string> { "One", "Two", "Three" };

			foreach(string item in items)
			{
				picker.Items.Add(item);
			}

			cellWrapper.BackgroundColor = Color.FromHex("#eee");
			stack.Orientation = StackOrientation.Vertical;

			stack.Children.Add(picker);
			stack.Children.Add(timePicker);
			stack.Children.Add(datePicker);

			cellWrapper.Children.Add(stack);
			View = cellWrapper;
		}

	}
}