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

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 2563, "NavigationPage should support queuing of navigation events", PlatformAffected.Android | PlatformAffected.WinPhone | PlatformAffected.iOS)]
	public class Issue2563 : ContentPage
	{
		public Issue2563 ()
		{
			var button = new Button {
				Text = "Click Me",
				VerticalOptions = LayoutOptions.Center,
				HorizontalOptions = LayoutOptions.Center
			};

			Content = button;

			var random = new Random ();
			button.Clicked += (sender, args) => {
				for (int i = 0; i < 10; i++) {
					button.Navigation.PushAsync (new ContentPage {
						Title = "Page " + i,
						Content = new Label {
							Text = "Page " + i,
							XAlign = TextAlignment.Center,
							YAlign = TextAlignment.Center
						}
					}, random.NextDouble () > 0.5);
				}

				for (int i = 0; i < 6; i++) {
					button.Navigation.PopAsync (random.NextDouble () > 0.5);
				}

				button.Navigation.PopToRootAsync (random.NextDouble () > 0.5);
			};
		}
	}
}