This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathNavBarTitleTestPage.cs
115 lines (105 loc) · 2.72 KB
/
NavBarTitleTestPage.cs
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Xamarin.Forms.Controls
{
public class NavBarTitleTestPage : ContentPage
{
public NavBarTitleTestPage()
{
var navTab = new NavigationPage { Title = "Hello 1 nav" };
navTab.PushAsync(GetPage(navTab));
var stackPages = new StackLayout();
var btn3 = new Button
{
Text = "tab",
Command = new Command(async () =>
{
var tabbed = new TabbedPage { Title = "Main Tab" };
tabbed.Children.Add(navTab);
tabbed.Children.Add(GetPage(navTab));
await Navigation.PushModalAsync(tabbed);
})
};
var btn4 = new Button
{
Text = "mdp",
Command = new Command(async () =>
{
var newNav = new NavigationPage { Title = "Hello 1 nav", BarBackgroundColor = Color.Pink, BarTextColor = Color.Blue };
var mdp = new FlyoutPage();
await newNav.PushAsync(GetPage(newNav));
mdp.Flyout = new ContentPage
{
Title = "Flyout",
BackgroundColor = Color.Red,
Content = new Button
{
Text = "new",
Command = new Command(() =>
{
mdp.Detail = new ContactsPage { Title = "hello 3" };
mdp.IsPresented = false;
})
}
};
mdp.Detail = newNav;
await Navigation.PushModalAsync(mdp);
})
};
var btn5 = new Button
{
Text = "nav",
Command = new Command(async () =>
{
var newNav = new NavigationPage { Title = "Hello 1 nav" };
await newNav.PushAsync(GetPage(newNav));
await Navigation.PushModalAsync(newNav);
})
};
var btn6 = new Button
{
Text = "change nav",
Command = new Command(() =>
{
(Parent as NavigationPage).BarBackgroundColor = Color.Blue;
(Parent as NavigationPage).BarTextColor = Color.Pink;
})
};
stackPages.Children.Add(btn3);
stackPages.Children.Add(btn4);
stackPages.Children.Add(btn5);
stackPages.Children.Add(btn6);
Content = stackPages;
}
static Page GetPage(NavigationPage navTab)
{
var stack = new StackLayout();
var newPage = new ContentPage { Title = "Hello 2", Content = stack };
var btn1 = new Button { Text = "next", Command = new Command(async () => await newPage.Navigation.PushAsync(new ContactsPage { Title = "hello 3" })) };
var btn2 = new Button
{
Text = "change nav",
Command = new Command(() =>
{
navTab.BarBackgroundColor = Color.Blue;
navTab.BarTextColor = Color.Pink;
})
};
var btn3 = new Button
{
Text = "pop modal",
Command = new Command(() =>
{
newPage.Navigation.PopModalAsync();
})
};
stack.Children.Add(btn1);
stack.Children.Add(btn2);
stack.Children.Add(btn3);
return newPage;
}
}
}