summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla27779.cs
blob: 71357786db3a99b036ad5171616c1e4ea70b044e (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
using System;

using Xamarin.Forms.CustomAttributes;
using System.Collections.Generic;
using Xamarin.Forms.Controls.Issues;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 27779, "Xamarin.Forms.ReadOnlyListAdapter.IndexOf throws NotImplementedExcpetion ")]
	public class Bugzilla27779 : TestContentPage // or TestMasterDetailPage, etc ...
	{
		ListView _listview;
		IReadOnlyList<Person> _itemsSource;

		public class Source : IReadOnlyList<Person>
		{
			List<Person> _items;
			public Source ()
			{
				_items = new List<Person> ();

				for (int i = 0; i < 100; i++) {
					_items.Add (new Person ("Person #" + i));
				}

			}
			#region IEnumerable implementation
			public IEnumerator<Person> GetEnumerator ()
			{
				return _items.GetEnumerator ();
			}
			#endregion
			#region IEnumerable implementation
			System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
			{
				return _items.GetEnumerator ();
			}
			#endregion
			#region IReadOnlyList implementation
			public Person this [int index] {
				get {
					return _items [index];
				}
			}
			#endregion
			#region IReadOnlyCollection implementation
			public int Count {
				get {
					return _items.Count;
				}
			}
			#endregion
			
		}
		protected override void Init ()
		{
			
			_itemsSource = new Source();

			_listview = new ListView {
				ItemsSource = _itemsSource
			};

			var btn = new Button { Text = "Set selected", AutomationId="btnSelect" };
			btn.Clicked+= (object sender, EventArgs e) => {
				_listview.SelectedItem = _itemsSource [0];
			};

			Content = new StackLayout { Children = { btn, _listview } };
		}

		protected override void OnAppearing ()
		{
			base.OnAppearing ();
		}

	}
}