summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2794.cs
blob: 6eaf2b45865e252fbb1e9b7294ad308edbc65e86 (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
using Xamarin.Forms;
using Xamarin.Forms.CustomAttributes;

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 2794, "TableView does not react on underlying collection change", PlatformAffected.Android)]
	public class Issue2794 : ContentPage
	{
		TableSection _dataSection;

		public Issue2794 ()
		{

			var tableView = new TableView ();
			_dataSection = new TableSection ();
			var cell1 = new TextCell { Text = "Cell1" };
			cell1.ContextActions.Add (new MenuItem {
				Text = "Delete me after",
				IsDestructive = true,
				Command = new Command (Delete),
				CommandParameter = 0
			});

			var cell2 = new TextCell { Text = "Cell2" };
			cell2.ContextActions.Add (new MenuItem {
				Text = "Delete me first",
				IsDestructive = true,
				Command = new Command (Delete),
				CommandParameter = 1
			});

			_dataSection.Add (cell1);
			_dataSection.Add (cell2);
			tableView.Root.Add (_dataSection);

			Content = tableView;
		}

		protected void Delete(object parameters)
		{
			int rowId = (int)parameters;
			_dataSection.RemoveAt (rowId);
		}
	}
}