summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3292.cs
blob: a6daf24dad12e6bb0db52a7f42616a43f94fe72f (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.Threading.Tasks;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Github, 3292, "TableSection.Title property binding fails in XAML")]
	public class Issue3292 : TestContentPage 
	{
		protected override void Init ()
		{
			var vm = new SomePageViewModel ();
			BindingContext = vm;

			var tableview = new TableView ();
			var section = new TableSection ();
			section.SetBinding (TableSectionBase.TitleProperty, new Binding ("SectionTitle"));
			var root = new TableRoot ();
			root.Add (section);
			tableview.Root = root;

			Content = tableview;

			vm.Init ();
		}

		[Preserve (AllMembers = true)]
		public class SomePageViewModel : INotifyPropertyChanged
		{
			string _sectionTitle;

			public SomePageViewModel()
			{
				SectionTitle = "Hello World";
			}

			public void Init()
			{
				Task.Delay(1000).ContinueWith(t =>
					{
						Device.BeginInvokeOnMainThread(() => {
							SectionTitle = "Hello World Changed";
						});
					});
			}

			public string SectionTitle
			{
				get { return _sectionTitle; }
				set
				{
					_sectionTitle = value;
					OnPropertyChanged();
				}
			}

			public event PropertyChangedEventHandler PropertyChanged;

			protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
			{
				var handler = PropertyChanged;
				if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
			}
		}

#if UITEST
		[Test]
		public void Issue3292Test ()
		{
			RunningApp.WaitForElement (q => q.Marked ("Hello World Changed"));
		}
#endif
	}
}