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
|
using Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries;
namespace Xamarin.Forms.Controls
{
public class PlatformSpecificsGallery : ContentPage
{
Page _originalRoot;
public PlatformSpecificsGallery()
{
var mdpiOSButton = new Button { Text = "MasterDetailPage (iOS)" };
var mdpWindowsButton = new Button { Text = "MasterDetailPage (Windows)" };
var npiOSButton = new Button() { Text = "NavigationPage (iOS)" };
var npWindowsButton = new Button { Text = "NavigationPage (Windows)" };
var tbiOSButton = new Button { Text = "TabbedPage (iOS)" };
var tbWindowsButton = new Button { Text = "TabbedPage (Windows)" };
var viselemiOSButton = new Button() { Text = "Visual Element (iOS)" };
var appAndroidButton = new Button() { Text = "Application (Android)" };
var tbAndroidButton = new Button { Text = "TabbedPage (Android)" };
var entryiOSButton = new Button() { Text = "Entry (iOS)" };
mdpiOSButton.Clicked += (sender, args) => { SetRoot(new MasterDetailPageiOS(new Command(RestoreOriginal))); };
mdpWindowsButton.Clicked += (sender, args) => { SetRoot(new MasterDetailPageWindows(new Command(RestoreOriginal))); };
npiOSButton.Clicked += (sender, args) => { SetRoot(NavigationPageiOS.Create(new Command(RestoreOriginal))); };
npWindowsButton.Clicked += (sender, args) => { SetRoot(new NavigationPageWindows(new Command(RestoreOriginal))); };
tbiOSButton.Clicked += (sender, args) => { SetRoot(new TabbedPageiOS(new Command(RestoreOriginal))); };
tbWindowsButton.Clicked += (sender, args) => { SetRoot(new TabbedPageWindows(new Command(RestoreOriginal))); };
viselemiOSButton.Clicked += (sender, args) => { SetRoot(new VisualElementiOS(new Command(RestoreOriginal))); };
appAndroidButton.Clicked += (sender, args) => { SetRoot(new ApplicationAndroid(new Command(RestoreOriginal))); };
tbAndroidButton.Clicked += (sender, args) => { SetRoot(new TabbedPageAndroid(new Command(RestoreOriginal))); };
entryiOSButton.Clicked += (sender, args) => { Navigation.PushAsync(new EntryPageiOS()); };
Content = new StackLayout
{
Children = { mdpiOSButton, mdpWindowsButton, npWindowsButton, tbiOSButton, tbWindowsButton, viselemiOSButton, appAndroidButton, tbAndroidButton, entryiOSButton }
};
}
void SetRoot(Page page)
{
var app = Application.Current as App;
if (app == null)
{
return;
}
_originalRoot = app.MainPage;
app.SetMainPage(page);
}
void RestoreOriginal()
{
if (_originalRoot == null)
{
return;
}
var app = Application.Current as App;
app?.SetMainPage(_originalRoot);
}
}
}
|