diff options
Diffstat (limited to 'Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs')
-rw-r--r-- | Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs b/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs new file mode 100644 index 00000000..67465da1 --- /dev/null +++ b/Xamarin.Forms.Controls/GalleryPages/PlatformSpecificsGallery.cs @@ -0,0 +1,54 @@ +using Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries; + +namespace Xamarin.Forms.Controls +{ + public class PlatformSpecificsGallery : ContentPage + { + Page _originalRoot; + + public PlatformSpecificsGallery() + { + var mdpWindowsButton = new Button { Text = "Master Detail Page (Windows)" }; + var npWindowsButton = new Button { Text = "Navigation Page (Windows)" }; + var tbWindowsButton = new Button { Text = "Tabbed Page (Windows)" }; + var navpageiOSButton = new Button() { Text = "Navigation Page (iOS)" }; + var viselemiOSButton = new Button() { Text = "Visual Element (iOS)" }; + var appAndroidButton = new Button() { Text = "Application (Android)" }; + + mdpWindowsButton.Clicked += (sender, args) => { SetRoot(new MasterDetailPageWindows(new Command(RestoreOriginal))); }; + npWindowsButton.Clicked += (sender, args) => { SetRoot(new NavigationPageWindows(new Command(RestoreOriginal))); }; + tbWindowsButton.Clicked += (sender, args) => { SetRoot(new TabbedPageWindows(new Command(RestoreOriginal))); }; + navpageiOSButton.Clicked += (sender, args) => { SetRoot(NavigationPageiOS.Create(new Command(RestoreOriginal))); }; + viselemiOSButton.Clicked += (sender, args) => { SetRoot(new VisualElementiOS(new Command(RestoreOriginal))); }; + appAndroidButton.Clicked += (sender, args) => { SetRoot(new ApplicationAndroid(new Command(RestoreOriginal))); }; + + Content = new StackLayout + { + Children = { mdpWindowsButton, npWindowsButton, tbWindowsButton, navpageiOSButton, viselemiOSButton, appAndroidButton } + }; + } + + 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); + } + } +}
\ No newline at end of file |