public MainNavigationViewModel(ISampleGalleryUIHost hostingUI)
        {
            _hostingUI = hostingUI;

            _hostingUI.BackStackStateChanged += (object sender, EventArgs args) =>
            {
                // Show or hide the global back button
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                    _hostingUI.CanGoBack ?
                    AppViewBackButtonVisibility.Visible :
                    AppViewBackButtonVisibility.Collapsed;
            };

            SystemNavigationManager.GetForCurrentView().BackRequested += (object backSender, BackRequestedEventArgs backArgs) =>
            {
                _hostingUI.GoBack();
            };



            // Build a collection used to populate the navigation menu. This is where you can define the display names of
            // each menu item and which page they map to.
            _mainMenuList = new List <NavigationItem>();
            AddNavigationItem(_mainMenuList, "Home", SampleCategory.None, typeof(HomePage), addEvenIfNoMatchingSamples: true, thumbnail: "ms-appx:///Assets/CategoryIcons/table_home_icon.png");
            AddNavigationItem(_mainMenuList, "Light", SampleCategory.Light, typeof(BaseCategoryPage), categoryDescription: CategoryDescription_Light, thumbnail: "ms-appx:///Assets/CategoryIcons/table_light_icon_bw.png");
            AddNavigationItem(_mainMenuList, "Depth", SampleCategory.Depth, typeof(BaseCategoryPage), categoryDescription: CategoryDescription_Depth, thumbnail: "ms-appx:///Assets/CategoryIcons/table_depth_icon_bw.png");
            AddNavigationItem(_mainMenuList, "Motion", SampleCategory.Motion, typeof(BaseCategoryPage), categoryDescription: CategoryDescription_Motion, thumbnail: "ms-appx:///Assets/CategoryIcons/table_motion_icon_bw.png");
            AddNavigationItem(_mainMenuList, "Material", SampleCategory.Material, typeof(BaseCategoryPage), categoryDescription: CategoryDescription_Material, thumbnail: "ms-appx:///Assets/CategoryIcons/table_material_icon_bw.png");
            AddNavigationItem(_mainMenuList, "Scale", SampleCategory.Scale, typeof(BaseCategoryPage), categoryDescription: CategoryDescription_Scale, thumbnail: "ms-appx:///Assets/CategoryIcons/table_scale_icon_bw.png");
            AddNavigationItem(_mainMenuList, "API Reference", SampleCategory.APIReference, typeof(BaseCategoryPage), categoryDescription: CategoryDescription_APIReference, thumbnail: "ms-appx:///Assets/CategoryIcons/table_reference_icon.png");

            s_instance = this;
        }
示例#2
0
        private void LoadUI(UIType type)
        {
            // Auto-detect the type to load if requested
            if (type == UIType.Auto)
            {
                if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5))
                {
                    type = UIType.NavView;
                }
                else
                {
                    type = UIType.Pivot;
                }
            }

            // Save off any properties that are stashed on the UI itself and need to be
            // forwarded on to the new UI, load it, and then reapply the saved properties
            object oldItemsSource = SampleCategories;


            UIElement actualContent;

            if (type == UIType.Pivot)
            {
                actualContent = new SampleGalleryPivotHost();
            }
            else
            {
                actualContent = new SampleGalleryNavViewHost();
            }


            Content        = actualContent;
            _actualContent = (ISampleGalleryUIHost)actualContent;


            SampleCategories = oldItemsSource;
        }