Ejemplo n.º 1
0
        private void BtnShowModalDemo_Clicked(object sender, RoutedEventArgs e)
        {
            Button button = new Button()
            {
                Content = "Pop",
                Width   = 200,
                Height  = 100
            };

            button.Click += (x, y) =>
            {
                Navigation.PopModal();
            };

            var lightPage = new LightContentPage()
            {
                Background = Brushes.Transparent, Content = button
            };
            LightAppBarButton appBarNav = new LightAppBarButton()
            {
                Label = "Navigation", Icon = new LightSymbolIcon()
                {
                    Symbol = Symbol.GlobalNavigationButton
                }
            };

            appBarNav.Click += (x, y) =>
            {
                lightPage.Background = Brushes.White;
            };

            lightPage.PrimaryTopBarCommands.Add(appBarNav);

            Navigation.PushModal(lightPage);
        }
Ejemplo n.º 2
0
        private void BtnNavigationPageDemo_Clicked(object sender, RoutedEventArgs e)
        {
            var startupPage = new LightNavigationPage(new Page1());

            LightAppBarButton appBarNav = new LightAppBarButton()
            {
                Label = "Navigation", Icon = new LightSymbolIcon()
                {
                    Symbol = Symbol.GlobalNavigationButton
                }
            };

            startupPage.PrimaryTopBarCommands.Add(appBarNav);

            LightAppBarButton appBarButton = new LightAppBarButton()
            {
                Label = "Home", Icon = new LightSymbolIcon()
                {
                    Symbol = Symbol.Home
                }
            };

            appBarButton.Click += (x, y) =>
            {
                ParentWindow.StartupPage = new RootPage();
            };
            startupPage.SecondaryTopBarCommands.Add(appBarButton);
            ParentWindow.StartupPage = startupPage;
        }
        void UpdateToolbar()
        {
            Control.PrimaryTopBarCommands.Clear();
            Control.SecondaryTopBarCommands.Clear();

            foreach (var item in Element.ToolbarItems)
            {
                LightAppBarButton appBar = new LightAppBarButton()
                {
                    Label = item.Text,
                    Tag   = item
                };

                appBar.SetValue(FrameworkElementAttached.PriorityProperty, item.Priority);

                if (item.Icon != null)
                {
                    Symbol   symbol;
                    Geometry geometry;

                    if (Enum.TryParse(item.Icon.File, true, out symbol))
                    {
                        appBar.Icon = new LightSymbolIcon()
                        {
                            Symbol = symbol
                        }
                    }
                    ;
                    else if (TryParseGeometry(item.Icon.File, out geometry))
                    {
                        appBar.Icon = new LightPathIcon()
                        {
                            Data = geometry
                        }
                    }
                    ;
                    else if (Path.GetExtension(item.Icon.File) != null)
                    {
                        appBar.Icon = new LightBitmapIcon()
                        {
                            UriSource = new Uri(item.Icon.File, UriKind.RelativeOrAbsolute)
                        }
                    }
                    ;
                }

                appBar.Click += (sender, e) =>
                {
                    if (appBar.Tag != null && appBar.Tag is ToolbarItem)
                    {
                        (appBar.Tag as ToolbarItem).Activate();
                    }
                };

                if (item.Order == ToolbarItemOrder.Default || item.Order == ToolbarItemOrder.Primary)
                {
                    Control.PrimaryTopBarCommands.Add(appBar);
                }
                else
                {
                    Control.SecondaryTopBarCommands.Add(appBar);
                }
            }
        }