summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla40408.cs
blob: 0fe2efc16f3e81df79b3af751fe089fcf252c769 (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
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System;

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

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 40408, "MasterDetailPage and TabbedPage only firing Appearing once", PlatformAffected.WinRT)]
	public class Bugzilla40408 : TestNavigationPage
	{
		protected override void Init()
		{
			BarBackgroundColor = Color.Red;
			
			var contentPage2 = new ContentPage();
			contentPage2.Title = "Page 2";
			contentPage2.BackgroundColor = Color.Green;

			contentPage2.Appearing += ContentPage2_Appearing;
			contentPage2.Disappearing += ContentPage2_Disappearing;
			
			var tabbedPage1 = new TabbedPage();
			tabbedPage1.Appearing += TabbedPage1_Appearing;
			tabbedPage1.Disappearing += TabbedPage1_Disappearing;

			var contentPage3 = new ContentPage() { Title = "Page 3" };
			contentPage3.BackgroundColor = Color.Pink;
			tabbedPage1.Children.Add(contentPage3);
			
			var masterDetailPage1 = new MasterDetailPage();
			masterDetailPage1.Title = "Page 3";
			var master1 = new ContentPage();
			master1.BackgroundColor = Color.Yellow;
			master1.Title = "Master 1";
			var detail1 = new ContentPage();
			detail1.Title = "Detail 1";
			detail1.BackgroundColor = Color.Purple;
			masterDetailPage1.Master = master1;
			masterDetailPage1.Detail = detail1;
			masterDetailPage1.BackgroundColor = Color.Yellow;

			masterDetailPage1.Appearing += MasterDetailPage1_Appearing;
			masterDetailPage1.Disappearing += MasterDetailPage1_Disappearing;
			
			var contentPage1 = new ContentPage();
			SetHasBackButton(contentPage1, true);
			contentPage1.BackgroundColor = Color.Blue;
			contentPage1.Title = "Page 1";
			var stack = new StackLayout();
			contentPage1.Content = stack;

			stack.Children.Add(new Button() { Text = "View Content", Command = new Command(() => PushAsync(contentPage2)) });
			stack.Children.Add(new Button() { Text = "View Master Detail", Command = new Command(() => PushAsync(masterDetailPage1)) });
			stack.Children.Add(new Button() { Text = "View Tabbed Page", Command = new Command(() => PushAsync(tabbedPage1)) });
			
			PushAsync(contentPage1);
		}

		void ContentPage2_Disappearing(object sender, EventArgs e)
		{
			DisplayAlert("Disappearing", "ContentPage", "OK");
		}

		void TabbedPage1_Disappearing(object sender, EventArgs e)
		{
			DisplayAlert("Disappearing", "TabbedPage", "OK");
		}

		void MasterDetailPage1_Disappearing(object sender, EventArgs e)
		{
			DisplayAlert("Disappearing", "MasterDetailPage", "OK");
		}

		void TabbedPage1_Appearing(object sender, EventArgs e)
		{
			DisplayAlert("Appearing", "TabbedPage", "OK");
		}

		void ContentPage2_Appearing(object sender, EventArgs e)
		{
			DisplayAlert("Appearing", "ContentPage", "OK");
		}

		void MasterDetailPage1_Appearing(object sender, EventArgs e)
		{
			DisplayAlert("Appearing", "MasterDetailPage", "OK");
		}
	}
}