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

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

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

namespace Xamarin.Forms.Controls
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 39908, " Back button hit quickly results in jumbled pages")]
	public class Bugzilla39908 : TestContentPage // or TestMasterDetailPage, etc ...
	{
		protected override void Init()
		{
			var label = "Root Page";

			Title = label;
			Content = new StackLayout
			{
				VerticalOptions = LayoutOptions.Center,
				Children = {
					new Label {
						HorizontalTextAlignment = TextAlignment.Center,
						Text = label
					},
					NewButton ()
				}
			};
		}



		private Button NewButton()
		{
			var newPageButton = new Button();
			newPageButton.Text = "Another one";
			newPageButton.Clicked += OnNewPage;

			return newPageButton;
		}

		private ContentPage NewPage()
		{
			var label = Navigation != null ? "Page " + (Navigation.NavigationStack.Count - 1) : "Root Page";

			return new ContentPage
			{
				Title = label,
				Content = new StackLayout
				{
					VerticalOptions = LayoutOptions.Center,
					Children = {
					new Label {
						HorizontalTextAlignment = TextAlignment.Center,
						Text = label
					},
					NewButton ()
				}
				}
			};
		}

		private async void OnNewPage(object sender, EventArgs e)
		{
			await Navigation.PushAsync(NewPage());
		}
	}
}