summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1644.cs
blob: 56cd97a389c293d89e9acf708c9e6357e489ce04 (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
using System;
using Xamarin.Forms;
using System.Collections.ObjectModel;

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 1644, "ListView reappearing and selecting its item causes jobject exception", PlatformAffected.Android)]
	public class Issue1644 : ContentPage
	{
		public ObservableCollection<string> Collection = new
			ObservableCollection<string>();

		public Issue1644 ()
		{
			for (int i = 0; i < 20; i++)
			{
				Collection.Add(DateTime.Now.ToString());
			}

			var listView = new ListView() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				HasUnevenRows = true, 
				ItemsSource = Collection,
			};

			listView.ItemSelected += (sender, e) => 
			{
				listView.SelectedItem = null;
			};

			var root = new StackLayout() {
				Padding = 5,
				Spacing = 5,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {
					listView
				}
			};

			Content = root;
		}
	}

	public class Issue1644Menu : MasterDetailPage
	{
		Issue1644 _secondPage = new Issue1644();

		public Issue1644Menu()
		{
			var button = new Button() {
				Text = "MAIN MENU BUTTON"
			};

			button.Clicked += (sender, e) => 
			{
				Navigation.PushAsync(_secondPage);
			};

			Master = new ContentPage() {
				Title = "Master"
			};

			Detail = new ContentPage() {
				Title = "Detail",
				Content = button
			};
		}
	}
}