Esempio n. 1
0
        private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
        {
            SelectionChangedRaised.Text = "True";
            // Reset argument type indicatiors
            SelectionChangedItemType.Text          = "null";
            SelectionChangedItemContainerType.Text = "null";

            m_selectionChangedEventsFired++;
            if (args.SelectedItem != null)
            {
                SelectionChangedItemType.Text = args.SelectedItem.GetType().ToString();

                var itemdata = args.SelectedItem as NavigationViewItem;
                if (itemdata != null)
                {
                    if (itemdata.Content != null)
                    {
                        NavView.Header = itemdata.Content + " as header";
                    }
                    else if (args.IsSettingsSelected) // to handle settings without content case in top nav
                    {
                        NavView.Header = "Settings as header";
                    }
                }
            }

            if (args.SelectedItemContainer != null)
            {
                SelectionChangedItemContainerType.Text = args.SelectedItemContainer.GetType().ToString();
            }
        }
        public void VerifyNavigationItemUIAType()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();
                Content     = navView;

                var menuItem1     = new NavigationViewItem();
                var menuItem2     = new NavigationViewItem();
                menuItem1.Content = "Item 1";
                menuItem2.Content = "Item 2";

                navView.MenuItems.Add(menuItem1);
                navView.MenuItems.Add(menuItem2);
                navView.Width = 1008; // forces the control into Expanded mode so that the menu renders
                Content.UpdateLayout();

                Verify.AreEqual(
                    AutomationControlType.ListItem,
                    NavigationViewItemAutomationPeer.CreatePeerForElement(menuItem1).GetAutomationControlType());

                navView.PaneDisplayMode = NavigationViewPaneDisplayMode.Top;
                Content.UpdateLayout();
                Verify.AreEqual(
                    AutomationControlType.TabItem,
                    NavigationViewItemAutomationPeer.CreatePeerForElement(menuItem1).GetAutomationControlType());
            });
        }
        // Disabled per GitHub Issue #211
        //[TestMethod]
        public void VerifyCanNotAddWUXItems()
        {
            if (!ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.NavigationViewItem"))
            {
                Log.Warning("WUX version of NavigationViewItem only available starting in RS3.");
                return;
            }

            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();

                var muxItem = new ModernWpf.Controls.NavigationViewItem {
                    Content = "MUX Item"
                };
                navView.MenuItems.Add(muxItem);

                navView.MenuItems.Add(new ModernWpf.Controls.NavigationViewItemSeparator());

                // No errors should occur here when we only use MUX items
                navView.UpdateLayout();

                var wuxItem = new Windows.UI.Xaml.Controls.NavigationViewItem {
                    Content = "WUX Item"
                };
                navView.MenuItems.Add(wuxItem);

                // But adding a WUX item should generate an exception (as soon as the new item gets processed)
                Verify.Throws <Exception>(() => { navView.UpdateLayout(); });
            });
        }
Esempio n. 4
0
        public void VerifySelectedItemIsNullWhenNoItemIsSelected()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();
                Content     = navView;

                var menuItem1     = new NavigationViewItem();
                menuItem1.Content = "Item 1";

                navView.MenuItems.Add(menuItem1);
                navView.Width = 1008; // forces the control into Expanded mode so that the menu renders
                Content.UpdateLayout(true);

                Verify.IsFalse(menuItem1.IsSelected);
                Verify.AreEqual(null, navView.SelectedItem);

                menuItem1.IsSelected = true;
                Content.UpdateLayout(true);

                Verify.IsTrue(menuItem1.IsSelected);
                Verify.AreEqual(menuItem1, navView.SelectedItem);

                menuItem1.IsSelected = false;
                Content.UpdateLayout(true);

                Verify.IsFalse(menuItem1.IsSelected);
                Verify.AreEqual(null, navView.SelectedItem, "SelectedItem should have been [null] as no item is selected");
            });
        }
        private NavigationView SetupNavigationView(NavigationViewPaneDisplayMode paneDisplayMode = NavigationViewPaneDisplayMode.Auto)
        {
            NavigationView navView = null;

            RunOnUIThread.Execute(() =>
            {
                navView = new NavigationView();
                navView.MenuItems.Add(new NavigationViewItem()
                {
                    Content = "Undo", Icon = new SymbolIcon(Symbol.Undo)
                });
                navView.MenuItems.Add(new NavigationViewItem()
                {
                    Content = "Cut", Icon = new SymbolIcon(Symbol.Cut)
                });

                navView.PaneTitle                  = "Title";
                navView.IsBackButtonVisible        = NavigationViewBackButtonVisible.Visible;
                navView.IsSettingsVisible          = true;
                navView.PaneDisplayMode            = paneDisplayMode;
                navView.OpenPaneLength             = 120.0;
                navView.ExpandedModeThresholdWidth = 600.0;
                navView.CompactModeThresholdWidth  = 400.0;
                navView.Width   = 800.0;
                navView.Height  = 600.0;
                navView.Content = "This is a simple test";
                Content         = navView;
                //Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
            });

            IdleSynchronizer.Wait();
            return(navView);
        }
        public void VerifyMenuItemAndContainerMappingMenuItemsSource()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();
                MUXControlsTestApp.App.TestContentRoot = navView;

                navView.MenuItemsSource = new ObservableCollection <String> {
                    "Item 1", "Item 2"
                };;
                navView.Width = 1008; // forces the control into Expanded mode so that the menu renders

                MUXControlsTestApp.App.TestContentRoot.UpdateLayout(true);


                var menuItem = "Item 2";
                // Get container for item
                var itemContainer             = navView.ContainerFromMenuItem(menuItem) as NavigationViewItem;
                bool correctContainerReturned = itemContainer != null && (itemContainer.Content as String) == menuItem;
                Verify.IsTrue(correctContainerReturned, "Correct container should be returned for passed in menu item.");

                // Get item for container
                var returnedItem         = navView.MenuItemFromContainer(itemContainer) as String;
                bool correctItemReturned = returnedItem != null && returnedItem == menuItem;
                Verify.IsTrue(correctItemReturned, "Correct item should be returned for passed in container.");

                MUXControlsTestApp.App.TestContentRoot = null;
            });
        }
 private void NavView_SelectionChanged(ModernWpf.Controls.NavigationView sender, ModernWpf.Controls.NavigationViewSelectionChangedEventArgs args)
 {
     if (args.SelectedItem != null)
     {
         var navItemTag = args.SelectedItemContainer.Tag.ToString();
         DoNavigate(navItemTag, args.RecommendedNavigationTransitionInfo);
     }
 }
Esempio n. 8
0
        private void NavView_PaneClosed(NavigationView sender, object args)
        {
            LastEdEventText.Text = "PaneClosed event fired";

            m_closedEventsFired++;
            ClosingEventCountTextBlock.Text = m_closingEventsFired + "-" + m_closedEventsFired;
            PaneOpenedOrClosedEvent.Text    = "Closed";
        }
Esempio n. 9
0
        private NavigationView SetupNavigationViewPaneContent(NavigationViewPaneDisplayMode paneDisplayMode = NavigationViewPaneDisplayMode.Auto)
        {
            NavigationView navView = null;

            RunOnUIThread.Execute(() =>
            {
                navView = new NavigationView();
                navView.MenuItems.Add(new NavigationViewItem()
                {
                    Content = "Undo", Icon = new SymbolIcon(Symbol.Undo)
                });
                navView.MenuItems.Add(new NavigationViewItem()
                {
                    Content = "Cut", Icon = new SymbolIcon(Symbol.Cut)
                });

                // Navigation View Pane Elements
                Button headerButton  = new Button();
                headerButton.Content = "Header Button";

                Button footerButton  = new Button();
                footerButton.Content = "Footer Button";

                // NavigationView Content Elements
                Button contentButtonOne  = new Button();
                contentButtonOne.Content = "Content Button One";

                Button contentButtonTwo  = new Button();
                contentButtonTwo.Content = "Content Button Two";
                contentButtonTwo.Margin  = new Thickness(50, 0, 0, 0);

                StackPanel contentStackPanel = new StackPanel();
                contentStackPanel.Children.Add(contentButtonOne);
                contentStackPanel.Children.Add(contentButtonTwo);

                // Set NavigationView Properties

                navView.PaneHeader                 = headerButton;
                navView.PaneFooter                 = footerButton;
                navView.Header                     = "NavigationView Header";
                navView.AutoSuggestBox             = new AutoSuggestBox();
                navView.Content                    = contentStackPanel;
                navView.IsBackButtonVisible        = NavigationViewBackButtonVisible.Visible;
                navView.IsSettingsVisible          = true;
                navView.PaneDisplayMode            = paneDisplayMode;
                navView.OpenPaneLength             = 300.0;
                navView.ExpandedModeThresholdWidth = 600.0;
                navView.CompactModeThresholdWidth  = 400.0;
                navView.Width  = 800.0;
                navView.Height = 600.0;
                Content        = navView;
                Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
            });

            IdleSynchronizer.Wait();
            return(navView);
        }
Esempio n. 10
0
        private async void navView_SelectionChanged(ModernWpf.Controls.NavigationView sender, ModernWpf.Controls.NavigationViewSelectionChangedEventArgs args)
        {
            var selectedItem = (NavigationViewItem)args.SelectedItem;

            if (selectedItem != null)
            {
                mdText.Text = await ReadAndFixMarkdown(selectedItem.Tag.ToString());

                mdText.Tag            = selectedItem.Tag.ToString();
                cmbLang.SelectedIndex = -1;
            }
        }
Esempio n. 11
0
        private void NavView_PaneClosing(NavigationView sender, NavigationViewPaneClosingEventArgs args)
        {
            if (CancelClosingEvents != null && (bool)CancelClosingEvents.IsChecked)
            {
                args.Cancel = true;
            }

            LastIngEventText.Text = "PaneClosing event fired";

            m_closingEventsFired++;
            ClosingEventCountTextBlock.Text = m_closingEventsFired + "-" + m_closedEventsFired;
        }
Esempio n. 12
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.MainPanel = ((ModernWpf.Controls.NavigationView)(target));
                return;

            case 2:
                this.CFrame = ((System.Windows.Controls.Frame)(target));
                return;
            }
            this._contentLoaded = true;
        }
 private void NavigationView_SelectionChanged6(ModernWpf.Controls.NavigationView sender, ModernWpf.Controls.NavigationViewSelectionChangedEventArgs args)
 {
     if (args.IsSettingsSelected)
     {
         contentFrame6.NavigateEx(typeof(SampleSettingsPage));
     }
     else
     {
         var    selectedItem = (ModernWpf.Controls.NavigationViewItem)args.SelectedItem;
         string pageName     = "SamplesCommon.SamplePages." + (string)selectedItem.Tag;
         Type   pageType     = typeof(SamplePage1).Assembly.GetType(pageName);
         contentFrame6.NavigateEx(pageType);
     }
 }
 private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
 {
     if (args.SelectedItem != null)
     {
         var itemdata = args.SelectedItem as NavigationViewItem;
         if (itemdata != null)
         {
             if (itemdata.Content != null)
             {
                 NavView.Header = itemdata.Content + " as header";
             }
         }
     }
 }
Esempio n. 15
0
        public void VerifyClearingItemsCollectionDoesNotCrashWhenItemSelectedOnTopNav()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView             = new NavigationView();
                navView.PaneDisplayMode = NavigationViewPaneDisplayMode.Top;

                var navViewItem1 = new NavigationViewItem()
                {
                    Content = "MenuItem 1",
                };
                var navViewItem2 = new NavigationViewItem()
                {
                    Content = "MenuItem 2"
                };

                Log.Comment("Set up the MenuItems collection");
                navView.MenuItems.Add(navViewItem1);
                navView.MenuItems.Add(navViewItem2);

                Content = navView;
                Content.UpdateLayout();

                Log.Comment("Set MenuItem 1 as selected");
                navView.SelectedItem = navViewItem1;
                Verify.AreEqual(navViewItem1, navView.SelectedItem, "MenuItem 1 should have been selected");

                // Clearing the MenuItems collection should not crash the app
                Log.Comment("Clear the MenuItems collection");
                navView.MenuItems.Clear();

                Log.Comment("Set up the MenuItemsSource collection");
                var itemsSource = new ObservableCollection <NavigationViewItem>()
                {
                    navViewItem1, navViewItem2
                };
                navView.MenuItemsSource = itemsSource;

                Content.UpdateLayout();

                Log.Comment("Set MenuItem 1 as selected");
                navView.SelectedItem = navViewItem1;
                Verify.AreEqual(navViewItem1, navView.SelectedItem, "MenuItem 1 should have been selected");

                // Clearing the MenuItemsSource collection should not crash the app
                Log.Comment("Clear the MenuItemsSource collection");
                itemsSource.Clear();
            });
        }
Esempio n. 16
0
        public void VerifySettingsItemTag()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();

                navView.IsSettingsVisible = true;
                navView.IsPaneOpen        = true;
                navView.PaneDisplayMode   = NavigationViewPaneDisplayMode.Left;
                Content = navView;
                Content.UpdateLayout();
                var settingsItem = (NavigationViewItem)navView.SettingsItem;
                Verify.AreEqual(settingsItem.Tag, "Settings");
            });
        }
 private void NavigationView_SelectionChanged5(ModernWpf.Controls.NavigationView sender, ModernWpf.Controls.NavigationViewSelectionChangedEventArgs args)
 {
     if (args.IsSettingsSelected)
     {
         contentFrame5.Navigate(typeof(SampleSettingsPage));
     }
     else
     {
         var    selectedItem    = (ModernWpf.Controls.NavigationViewItem)args.SelectedItem;
         string selectedItemTag = (string)selectedItem.Tag;
         sender.Header = "Sample Page " + selectedItemTag.Substring(selectedItemTag.Length - 1);
         string pageName = "SamplesCommon.SamplePages." + selectedItemTag;
         Type   pageType = typeof(SamplePage1).Assembly.GetType(pageName);
         contentFrame5.Navigate(pageType);
     }
 }
Esempio n. 18
0
        public void VerifyValuesCoercion()
        {
            RunOnUIThread.Execute(() =>
            {
                NavigationView navView = new NavigationView();

                navView.CompactModeThresholdWidth  = -1;
                navView.ExpandedModeThresholdWidth = -1;
                navView.CompactPaneLength          = -1;
                navView.OpenPaneLength             = -1;

                Verify.AreEqual(0, navView.CompactModeThresholdWidth, "Should coerce negative CompactModeThresholdWidth values to 0");
                Verify.AreEqual(0, navView.ExpandedModeThresholdWidth, "Should coerce negative ExpandedModeThresholdWidth values to 0");
                Verify.AreEqual(0, navView.CompactPaneLength, "Should coerce negative CompactPaneLength values to 0");
                Verify.AreEqual(0, navView.OpenPaneLength, "Should coerce negative OpenPaneLength values to 0");
            });
        }
Esempio n. 19
0
        public void VerifyOverflowButtonToolTip()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView             = new NavigationView();
                navView.PaneDisplayMode = NavigationViewPaneDisplayMode.Top;

                Content = navView;
                Content.UpdateLayout();

                var overflowButton = VisualTreeUtils.FindVisualChildByName(navView, "TopNavOverflowButton") as Button;
                var toolTipObject  = ToolTipService.GetToolTip(overflowButton);

                bool testCondition = toolTipObject is ToolTip toolTip && toolTip.Content.Equals("More");
                Verify.IsTrue(testCondition, "ToolTip text should have been \"More\".");
            });
        }
        private void NavigationView_SelectionChanged4(ModernWpf.Controls.NavigationView sender, ModernWpf.Controls.NavigationViewSelectionChangedEventArgs args)
        {
            if (args.IsSettingsSelected)
            {
                contentFrame4.NavigateEx(typeof(SampleSettingsPage));
            }
            else
            {
                Debug.WriteLine("Before hitting sample page 1");

                var    selectedItem    = (Category)args.SelectedItem;
                string selectedItemTag = selectedItem.Name;
                sender.Header = "Sample Page " + selectedItemTag.Substring(selectedItemTag.Length - 1);
                string pageName = "SamplesCommon.SamplePages." + "SamplePage1";
                Type   pageType = typeof(SamplePage1).Assembly.GetType(pageName);
                contentFrame4.NavigateEx(pageType);
            }
        }
Esempio n. 21
0
        private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
        {
            m_itemInvokedEventsFired++;

            // Reset argument type indicatiors
            ItemInvokedItemType.Text          = "null";
            ItemInvokedItemContainerType.Text = "null";

            if (args.InvokedItem != null)
            {
                ItemInvokedItemType.Text = args.InvokedItem.GetType().ToString();
            }

            if (args.InvokedItemContainer != null)
            {
                ItemInvokedItemContainerType.Text = args.InvokedItemContainer.GetType().ToString();
            }
        }
 private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
 {
     if (args.SelectedItem != null)
     {
         var itemdata = args.SelectedItem as NavigationViewItem;
         if (itemdata != null)
         {
             if (itemdata.Content != null)
             {
                 NavView.Header = itemdata.Content + " as header";
             }
             else if (args.IsSettingsSelected) // to handle settings without content case in top nav
             {
                 NavView.Header = "Settings as header";
             }
         }
     }
 }
Esempio n. 23
0
        public void VerifyPaneProperties()
        {
            RunOnUIThread.Execute(() =>
            {
                NavigationView navView = new NavigationView();

                // These properties are template-bound to SplitView properties, so testing getters/setters should be sufficient
                navView.IsPaneOpen        = false;
                navView.CompactPaneLength = 100.0;
                navView.OpenPaneLength    = 200.0;

                Verify.AreEqual(false, navView.IsPaneOpen);
                Verify.AreEqual(100.0, navView.CompactPaneLength);
                Verify.AreEqual(200.0, navView.OpenPaneLength);

                navView.IsPaneOpen = true;
                Verify.AreEqual(true, navView.IsPaneOpen);
            });
        }
Esempio n. 24
0
        private void NavView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
        {
            switch (args.DisplayMode)
            {
            case NavigationViewDisplayMode.Minimal:
                DisplayModeTextBox.Text       = "Minimal";
                DisplayModeTextBox.Foreground = new System.Windows.Media.SolidColorBrush(Colors.DodgerBlue);
                break;

            case NavigationViewDisplayMode.Compact:
                DisplayModeTextBox.Text       = "Compact";
                DisplayModeTextBox.Foreground = new System.Windows.Media.SolidColorBrush(Colors.DarkMagenta);
                break;

            case NavigationViewDisplayMode.Expanded:
                DisplayModeTextBox.Text       = "Expanded";
                DisplayModeTextBox.Foreground = new System.Windows.Media.SolidColorBrush(Colors.DarkRed);
                break;
            }
        }
Esempio n. 25
0
        public void VerifyNavigationViewItemInFooterDoesNotCrash()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();

                Content = navView;

                var navViewItem = new NavigationViewItem()
                {
                    Content = "Footer item"
                };

                navView.PaneFooter = navViewItem;

                navView.Width = 1008; // forces the control into Expanded mode so that the menu renders
                Content.UpdateLayout(true);

                // If we don't get here, app has crashed. This verify is just making sure code got run
                Verify.IsTrue(true);
            });
        }
Esempio n. 26
0
        public void VerifySettingsItemToolTip()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();

                navView.IsSettingsVisible = true;
                navView.IsPaneOpen        = true;
                navView.PaneDisplayMode   = NavigationViewPaneDisplayMode.Left;
                Content = navView;
                Content.UpdateLayout();
                var settingsItem = (NavigationViewItem)navView.SettingsItem;

                var toolTip = ToolTipService.GetToolTip(settingsItem);
                Verify.IsNull(toolTip, "Verify tooltip is disabled when pane is open");

                navView.IsPaneOpen = false;
                Content.UpdateLayout();

                toolTip = ToolTipService.GetToolTip(settingsItem);
                Verify.IsNotNull(toolTip, "Verify tooltip is enabled when pane is closed");
            });
        }
Esempio n. 27
0
        public void VerifyMenuItemAndContainerMappingMenuItems()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();
                MUXControlsTestApp.App.TestContentRoot = navView;

                var menuItem1     = new NavigationViewItem();
                var menuItem2     = new NavigationViewItem();
                menuItem1.Content = "Item 1";
                menuItem2.Content = "Item 2";

                navView.MenuItems.Add(menuItem1);
                navView.MenuItems.Add(menuItem2);
                navView.Width = 1008; // forces the control into Expanded mode so that the menu renders

                MUXControlsTestApp.App.TestContentRoot.UpdateLayout(true);

                // Get container for item
                var itemContainer             = navView.ContainerFromMenuItem(menuItem2) as NavigationViewItem;
                bool correctContainerReturned = itemContainer != null && itemContainer == menuItem2;
                Verify.IsTrue(correctContainerReturned, "Correct container should be returned for passed in menu item.");

                // Get item for container
                var returnedItem         = navView.MenuItemFromContainer(menuItem2) as NavigationViewItem;
                bool correctItemReturned = returnedItem != null && returnedItem == menuItem2;
                Verify.IsTrue(correctItemReturned, "Correct item should be returned for passed in container.");

                // Try to get an item that is not in the NavigationView
                NavigationViewItem menuItem3            = new NavigationViewItem();
                menuItem3.Content                       = "Item 3";
                var returnedItemForNonExistentContainer = navView.MenuItemFromContainer(menuItem3);
                Verify.IsTrue(returnedItemForNonExistentContainer == null, "Returned item should be null.");

                MUXControlsTestApp.App.TestContentRoot = null;
            });
        }
Esempio n. 28
0
        private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
        {
            m_itemInvokedEventsFired++;

            // Reset argument type indicatiors
            ItemInvokedItemType.Text          = "null";
            ItemInvokedItemContainerType.Text = "null";

            if (args.InvokedItem != null)
            {
                ItemInvokedItemType.Text = args.InvokedItem.GetType().ToString();
            }

            if (args.InvokedItemContainer != null)
            {
                ItemInvokedItemContainerType.Text = args.InvokedItemContainer.GetType().ToString();
            }

            var curSelected = sender.SelectedItem as NavigationViewItem;
            var text        = args.InvokedItem as string;

            if (curSelected != null && (string)curSelected.Content == text)
            {
                if (InvokedItemState.Text == "ItemWasSelectedInItemInvoked")
                {
                    InvokedItemState.Text = "ItemWasInvokedSecomdTimeWithCorrectSelection";
                }
                else
                {
                    InvokedItemState.Text = "ItemWasSelectedInItemInvoked";
                }
            }
            else
            {
                InvokedItemState.Text = "Error:ItemUnselectedInItemInvoked";
            }
        }
        private void NavigationView_SelectionChanged8(ModernWpf.Controls.NavigationView sender, ModernWpf.Controls.NavigationViewSelectionChangedEventArgs args)
        {
            /* NOTE: for this function to work, every NavigationView must follow the same naming convention: nvSample# (i.e. nvSample3),
             * and every corresponding content frame must follow the same naming convention: contentFrame# (i.e. contentFrame3) */

            // Get the sample number
            string sampleNum = (sender.Name).Substring(8);

            Debug.Print("num: " + sampleNum + "\n");

            if (args.IsSettingsSelected)
            {
                contentFrame8.NavigateEx(typeof(SampleSettingsPage));
            }
            else
            {
                var    selectedItem    = (ModernWpf.Controls.NavigationViewItem)args.SelectedItem;
                string selectedItemTag = ((string)selectedItem.Tag);
                sender.Header = "Sample Page " + selectedItemTag.Substring(selectedItemTag.Length - 1);
                string pageName = "SamplesCommon.SamplePages." + selectedItemTag;
                Type   pageType = typeof(SamplePage1).Assembly.GetType(pageName);
                contentFrame8.NavigateEx(pageType);
            }
        }
Esempio n. 30
0
        public void VerifySingleSelection()
        {
            RunOnUIThread.Execute(() =>
            {
                var navView = new NavigationView();
                Content     = navView;

                var menuItem1     = new NavigationViewItem();
                var menuItem2     = new NavigationViewItem();
                menuItem1.Content = "Item 1";
                menuItem2.Content = "Item 2";

                navView.MenuItems.Add(menuItem1);
                navView.MenuItems.Add(menuItem2);
                navView.Width = 1008; // forces the control into Expanded mode so that the menu renders
                Content.UpdateLayout(true);

                Verify.IsFalse(menuItem1.IsSelected);
                Verify.IsFalse(menuItem2.IsSelected);
                Verify.AreEqual(navView.SelectedItem, null);

                menuItem1.IsSelected = true;
                Content.UpdateLayout(true);

                Verify.IsTrue(menuItem1.IsSelected);
                Verify.IsFalse(menuItem2.IsSelected);
                Verify.AreEqual(navView.SelectedItem, menuItem1);

                menuItem2.IsSelected = true;
                Content.UpdateLayout(true);

                Verify.IsTrue(menuItem2.IsSelected);
                Verify.IsFalse(menuItem1.IsSelected, "MenuItem1 should have been deselected when MenuItem2 was selected");
                Verify.AreEqual(navView.SelectedItem, menuItem2);
            });
        }