public NavigationDemoPage(string title = "Navigation")
        {
            Title = title;
            PageExtensions.AddPageLog(this);

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Children        =
                {
                    new DemoLabel("Navigation stack:"),
                    new DemoButton("PushAsync")
                    {
                        Command = new Command(o => Navigation.PushAsync(new NavigationDemoPage(title + " >"))),
                    },
                    new DemoButton("PopAsync")
                    {
                        Command = new Command(obj => Navigation.PopAsync()),
                    },
                    new DemoButton("PopToRootAsync")
                    {
                        Command = new Command(obj => Navigation.PopToRootAsync()),
                    },
                    new DemoLabel("Modal stack:"),
                    new DemoButton("PushModalAsync")
                    {
                        Command = new Command(o => Navigation.PushModalAsync(new NavigationDemoPage(title + " ^"))),
                    },
                    new DemoButton("PopModalAsync")
                    {
                        Command = new Command(obj => Navigation.PopModalAsync()),
                    },
                    new DemoButton("PushModalAsync NavigationPage")
                    {
                        Command = new Command(o => Navigation.PushModalAsync(new NavigationPage(new NavigationDemoPage(title + " ^")).AddPageLog())),
                    },
                    new DemoLabel("Flyout:"),
                    new DemoButton("Toggle Flyout MainPage")
                    {
                        Command = new Command(obj => (Application.Current as App).ToggleFlyout()),
                    },
                    new DemoButton("Show Alert")
                    {
                        Command = new Command(obj => ShowAlert()),
                    },
                },
            };

            if (title.EndsWith("^", StringComparison.Ordinal))
            {
                (Content as StackLayout).Children.Insert(0, new DemoLabel("Title: " + title));
            }
        }
示例#2
0
        public ElementDemoPage()
        {
            Title = "Element demo";
            PageExtensions.AddPageLog(this);

            var searchbar = new SearchBar {
                AutomationId    = "searchbar_automation_id",
                BackgroundColor = Color.White,
                HeightRequest   = 48, // HACK: https://bugzilla.xamarin.com/show_bug.cgi?id=43975
            };

            searchbar.TextChanged += delegate {
                Application.Current.MainPage.
                DisplayAlert("SearchBar Content",
                             searchbar.Text != null ? $"<{searchbar.Text}>" : "null",
                             "Ok");
            };

            Content = new ScrollView {
                Content = new StackLayout {
                    AutomationId = "page-stack",
                    Children     =
                    {
                        searchbar,
                        new DemoButton("Button"),
                        new DemoLabel("Label").WithGestureRecognizer(),
                        CreateFormattedLabel(),
                        new DemoStack(),
                        new DemoGrid(),
                        new ContentView {
                            Content = new DemoLabel("label within ContentView")
                        },
                        new DemoEntry("entry_automation_id",           "Placeholder"),
                        new DemoEditor("editor_automation_id",         "editor content"),
                        new DemoLabel("Invisible Label").Invisible(),
                        new DemoSlider("slider_automation_id",                                   0,120, 42),
                        new DemoPicker("picker_automation_id",         "Pick an item",             new List <PickerObject> {
                            new PickerObject("Item A"),                new PickerObject("Item B"), new PickerObject("Item C")
                        }),
                        new DemoCountdown(),
                        new DemoImage("logo.png"),
                    },
                },
            };

            ToolbarItems.Add(new DemoToolbarItem());
        }
示例#3
0
        public TabbedPageDemoPage()
        {
            Title = "TabbedPage";
            PageExtensions.AddPageLog(this);

            var contentPageA = new ContentPage {
                Title   = "Tab A",
                Content = new StackLayout {
                    Children =
                    {
                        new Label  {
                            Text = "This is content on tab A"
                        },
                        new Button {
                            Text = "Open ModalPage", Command = new Command(OpenModalPage)
                        },
                        new Button {
                            Text = "Open Subpage", Command = new Command(OpenSubpage)
                        },
                    }
                }
            }.AddPageLog();

            var contentPageB = new ContentPage {
                Title   = "Tab B",
                Content = new StackLayout {
                    Children =
                    {
                        new Label {
                            Text = "This is content on tab B"
                        }
                    },
                },
                ToolbarItems = { new DemoToolbarItem() }
            }.AddPageLog();

            Children.Add(contentPageA);
            Children.Add(contentPageB);
        }