private bool IsMenuItemForPageType(WinUI.NavigationViewItem menuItem, Type sourcePageType)
        {
            var navigatedPageKey = NavigationService.GetNameOfRegisteredPage(sourcePageType);
            var pageKey          = menuItem.Tag as string;

            return(pageKey == navigatedPageKey);
        }
Exemple #2
0
        private async void NavMain_OnSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
        {
            NavigationViewItem nowitem = (NavigationViewItem)sender.SelectedItem;

            if (nowitem.Tag.ToString() == "PageMe" && !Common.Logined)
            {
                await DialogLogin.ShowAsync();

                return;
            }

            switch (nowitem.Tag.ToString())
            {
            case "PageMe":
                Common.BaseFrame.Navigate(typeof(Pages.Me), null, new EntranceNavigationTransitionInfo());
                break;

            case "PageHome":
                Common.BaseFrame.Navigate(typeof(Pages.Home), null, new EntranceNavigationTransitionInfo());
                break;

            case "PageSearch":
                Common.BaseFrame.Navigate(typeof(Search), null, new EntranceNavigationTransitionInfo());
                break;

            case "PageSettings":
                Common.BaseFrame.Navigate(typeof(Pages.Settings), null, new EntranceNavigationTransitionInfo());
                break;
            }
        }
Exemple #3
0
 private static XamlIslands.NavigationViewItem CreateMenu(string menuName)
 {
     XamlIslands.NavigationViewItem item = new XamlIslands.NavigationViewItem
     {
         Name = menuName, Content = menuName, Tag = menuName
     };
     return(item);
 }
        private void Frame_Navigated(object sender, NavigationEventArgs e)
        {
            IsBackEnabled = NavigationService.CanGoBack;
            var selectedItem = GetSelectedItem(_navigationView.MenuItems, e.SourcePageType);

            if (selectedItem != null)
            {
                Selected = selectedItem;
            }
        }
        private static XamlIslands.NavigationViewItem CreateMenu(string menuName, string IconName)
        {
            XamlIslands.NavigationViewItem mnuItem = new XamlIslands.NavigationViewItem
            {
                Name    = menuName,
                Content = menuName,
                Tag     = menuName
            };
            var mnuIcon = new XamlIslands.FontIcon {
                Glyph = IconName
            };

            mnuItem.Icon = mnuIcon;
            return(mnuItem);
        }
        public async Task When_NavView()
        {
            var SUT = new MyNavigationView()
            {
                IsSettingsVisible = false
            };

            SUT.MenuItems.Add(new NavigationViewItem {
                DataContext = this, Content = "Item 1"
            });

            WindowHelper.WindowContent = SUT;

            await WindowHelper.WaitForLoaded(SUT);

            var list  = SUT.MenuItemsHost;
            var panel = list.ItemsPanelRoot;

            Assert.IsNotNull(panel);

            NavigationViewItem item2 = null;
            await SUT.Dispatcher.RunIdleAsync(a => SUT.MenuItems.Add(new NavigationViewItem()
            {
                DataContext = this, Content = "Item 2"
            }));

            await SUT.Dispatcher.RunIdleAsync(a => SUT.MenuItems.RemoveAt(1));

            await SUT.Dispatcher.RunIdleAsync(a => SUT.MenuItems.Add(item2 = new NavigationViewItem()
            {
                DataContext = this, Content = "Item 2"
            }));

            await WindowHelper.WaitForLoaded(item2);

            var children =
#if __ANDROID__ || __IOS__ // ItemsStackPanel is just a Xaml facade on Android/iOS, its Children list isn't populated
                list.GetItemsPanelChildren();
#else
                panel.Children;
#endif
            Assert.AreEqual(item2, children.Last());
        }
        private void NavView_SelectionChanged(Windows.UI.Xaml.Controls.NavigationView sender, Windows.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args)
        {
            Windows.UI.Xaml.Controls.NavigationViewItem e = sender.SelectedItem as Windows.UI.Xaml.Controls.NavigationViewItem;
            String Name = e.Name.ToString();

            switch (Name)
            {
            case "SearchFrame":
                contentFrame.Navigate(typeof(SearchPage));
                break;

            case "SettingsPage":
                contentFrame.Navigate(typeof(CodeSettingsPage));
                break;

            case "DocumentFrame":
                contentFrame.Navigate(typeof(DocumentPage));
                break;
            }
        }
        private void Host_ChildChanged(object sender, EventArgs e)
        {
            try
            {
                WindowsXamlHost host = (WindowsXamlHost)sender;
                if (host.Child is UIControls.NavigationView navigationView)
                {
                    var homeItem = new UIControls.NavigationViewItem()
                    {
                        Content = "Home",
                        Icon    = new UIControls.FontIcon()
                        {
                            FontFamily = segoeFontFamily,
                            Glyph      = "\uE80F",
                        }
                    };

                    var shopItem = new UIControls.NavigationViewItem()
                    {
                        Content = "Shop",
                        Icon    = new UIControls.FontIcon()
                        {
                            FontFamily = segoeFontFamily,
                            Glyph      = "\uE719",
                        }
                    };

                    var paymentsItem = new UIControls.NavigationViewItem()
                    {
                        Content = "Payments",
                        Icon    = new UIControls.FontIcon()
                        {
                            FontFamily = segoeFontFamily,
                            Glyph      = "\uE8C7",
                        }
                    };

                    var reportsItem = new UIControls.NavigationViewItem()
                    {
                        Content = "Reports",
                        Icon    = new UIControls.FontIcon()
                        {
                            FontFamily = segoeFontFamily,
                            Glyph      = "\uE9F9",
                        }
                    };

                    var locateBranchItem = new UIControls.NavigationViewItem()
                    {
                        Content = "Locate Branch",
                        Icon    = new UIControls.FontIcon()
                        {
                            FontFamily = segoeFontFamily,
                            Glyph      = "\uE707",
                        }
                    };

                    var profileSettingsItem = new UIControls.NavigationViewItem()
                    {
                        Content = "Profile Settings",
                        Icon    = new UIControls.FontIcon()
                        {
                            FontFamily = segoeFontFamily,
                            Glyph      = "\uEF58",
                        }
                    };

                    navigationView.MenuItems.Add(homeItem);
                    navigationView.MenuItems.Add(shopItem);
                    navigationView.MenuItems.Add(paymentsItem);
                    navigationView.MenuItems.Add(reportsItem);
                    navigationView.MenuItems.Add(locateBranchItem);
                    navigationView.MenuItems.Add(profileSettingsItem);

                    frame = new UIControls.Frame();
                    navigationView.Content = frame;

                    navigationView.SelectionChanged += NavigationView_SelectionChanged;
                }
            }
            catch (Exception)
            {
            }
        }