summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla33714.cs
blob: 2ae7f3881564236f87f3a194dc8d18c32e2035a1 (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
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms.CustomAttributes;

namespace Xamarin.Forms.Controls.Issues
{

	[Issue (IssueTracker.Bugzilla, 33714, "[WP] Navigating Back Within MasterDetailPage.Detail Causes Crash", NavigationBehavior.PushModalAsync)]
    public class Bugzilla33714 : MasterDetailPage
	{
		public Bugzilla33714 ()
		{
            Master = new MasterPage (this);
            Detail = new NavigationPage (new ContentPage
            {
                Title = "Home",
                Content = new StackLayout
                {
                    Children = {
                        new Label { Text = "This is the home detail page"}
                    }
                }
            });
		}

		public class MoreDetail : ContentPage
		{
			public MoreDetail ()
			{
				Content = new StackLayout {
					Children = {
						new Label { Text = "More details" },
						new Button { Text = "Go to more detail page", Command = new Command(async () => await Navigation.PushAsync(new MoreDetail()))},
						new Button { Text = "Go back", Command = new Command(async () => await Navigation.PopAsync())}
					}
				};
			}
		}

		public class DetailPage : ContentPage
		{
			public DetailPage ()
			{
				Title = "Detail";
				Content = new StackLayout {
					Children = {
						new Label { Text = "This is a Detail ContentPage" },
						new Button { Text = "Go to more detail page", Command = new Command(async () => await Navigation.PushAsync(new MoreDetail()))}
					}
				};
			}
		}

		public class MasterPage : ContentPage
		{
			readonly MasterDetailPage _masterPage;
			List<string> _items;

			public MasterPage (MasterDetailPage masterPage)
			{
				_masterPage = masterPage;
				Title = "Menu";

				for (int i = 0; i < 5; i++ )
				{
					if (i == 0) _items = new List<string>();

					_items.Add("Menu Items");
				}

				var list = new ListView { ItemsSource = _items, RowHeight = 100, HasUnevenRows = true };
				list.ItemSelected += list_ItemSelected;

				Content = list;
			}

			void list_ItemSelected(object sender, SelectedItemChangedEventArgs e)
			{
				//var listView = (ListView) sender;

				_masterPage.Detail = new NavigationPage(new DetailPage());
			}
		}
    }
}