Пример #1
0
        /// <summary>
        ///     Check for the conditions where the navigation pane does not occupy the space under the floating
        ///     hamburger button and trigger the event.
        /// </summary>
        private void CheckTogglePaneButtonSizeChanged()
        {
            if (RootSplitView.DisplayMode == SplitViewDisplayMode.Inline ||
                RootSplitView.DisplayMode == SplitViewDisplayMode.Overlay ||
                RootSplitView.DisplayMode == SplitViewDisplayMode.CompactOverlay)
            {
                var transform = TogglePaneButton.TransformToVisual(this);
                var rect      =
                    transform.TransformBounds(new Rect(0, 0, TogglePaneButton.ActualWidth, TogglePaneButton.ActualHeight));
                TogglePaneButtonRect = rect;
            }
            else
            {
                TogglePaneButtonRect = new Rect();
            }

            if (RootSplitView.DisplayMode == SplitViewDisplayMode.Overlay)
            {
                RootSplitView.IsPaneOpen = false;
            }

            var handler = TogglePaneButtonRectChanged;

            handler?.DynamicInvoke(this, TogglePaneButtonRect);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the AppShell, sets the static 'Current' reference,
        /// adds callbacks for Back requests and changes in the SplitView's DisplayMode, and
        /// provide the nav menu list with the data to display.
        /// </summary>
        public AppShell(IWalletRepository walletRepository)
        {
            InitializeComponent();
            _walletRepository = walletRepository;

            _navlist = BuildNavigationList();

            Loaded += (sender, args) =>
            {
                Current = this;
                TogglePaneButton.Focus(FocusState.Programmatic);
            };

            RootSplitView.RegisterPropertyChangedCallback(
                SplitView.DisplayModeProperty,
                (s, a) =>
            {
                // Ensure that we update the reported size of the TogglePaneButton when the SplitView's
                // DisplayMode changes.
                CheckTogglePaneButtonSizeChanged();
            });

            SystemNavigationManager.GetForCurrentView().BackRequested += SystemNavigationManager_BackRequested;

            NavMenuList.ItemsSource = _navlist;
        }
Пример #3
0
        private protected override void OnApplyTemplateCore()
        {
            _shellSplitView = new ShellSplitView(RootSplitView);
            _shellSplitView.FlyoutBackdrop = _flyoutBackdrop;
            TogglePaneButton?.SetAutomationPropertiesAutomationId("OK");

            base.OnApplyTemplateCore();
        }
Пример #4
0
 /// <summary>
 /// Check for the conditions where the navigation pane does not occupy the space under the floating
 /// hamburger button and trigger the event.
 /// </summary>
 private void CheckTogglePaneButtonSizeChanged()
 {
     TogglePaneButtonRect =
         RootSplitView.DisplayMode == SplitViewDisplayMode.Inline ||
         RootSplitView.DisplayMode == SplitViewDisplayMode.Overlay
             ? TogglePaneButton.TransformToVisual(this).TransformBounds(
             new Rect(0, 0, TogglePaneButton.ActualWidth, TogglePaneButton.ActualHeight))
             : new Rect();
     TogglePaneButtonRectChanged?.Invoke(this, this.TogglePaneButtonRect);
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the AppShell, sets the static 'Current' reference,
        /// adds callbacks for Back requests and changes in the SplitView's DisplayMode, and
        /// provide the nav menu list with the data to display.
        /// </summary>
        /// <param name="frame">The root frame of the application.</param>
        /// <param name="navigationItems">The navigation items.</param>
        /// <param name="bottomDockedNavigationItems">The optional navigation items that are docked at the bottom.</param>
        public AppShell(Frame frame, IEnumerable <NavMenuItem> navigationItems, IEnumerable <NavMenuItem> bottomDockedNavigationItems = null)
        {
            InitializeComponent();
            RootSplitView.Content = frame;
            _rootFrame            = frame;

            _rootFrame.Navigated += OnNavigatedToPage;

            Loaded += (sender, args) =>
            {
                Current = this;

                SelectNavigationItem(NavigationService.CurrentPageType);

                TogglePaneButton.Focus(FocusState.Programmatic);
            };

            SizeChanged += (s, e) =>
            {
                // update the button size when the frame size changes, due to possible changes of the adaptive UI
                CheckTogglePaneButtonSizeChanged();
            };

            if (navigationItems == null || navigationItems.Count() == 0)
            {
                throw new ArgumentException("There must be at least one top-level navigation item. Did you forgot to override a method in UniversalApp?");
            }

            NavigationItems         = new List <NavMenuItem>(navigationItems);
            NavMenuList.ItemsSource = navigationItems;

            if (bottomDockedNavigationItems != null && bottomDockedNavigationItems.Count() > 0)
            {
                NavMenuListBottomDock.ItemsSource = bottomDockedNavigationItems;

                foreach (var item in bottomDockedNavigationItems)
                {
                    NavigationItems.Add(item);
                }
            }
            else
            {
                NavMenuSeperator.Visibility = Visibility.Collapsed;
            }
        }
Пример #6
0
        /// <summary>
        /// Check for the conditions where the navigation pane does not occupy the space under the floating
        /// hamburger button and trigger the event.
        /// </summary>
        private void CheckTogglePaneButtonSizeChanged()
        {
            if (RootSplitView.DisplayMode == SplitViewDisplayMode.Inline ||
                RootSplitView.DisplayMode == SplitViewDisplayMode.Overlay)
            {
                GeneralTransform transform = TogglePaneButton.TransformToVisual(this);
                Rect             rect      = transform.TransformBounds(new Rect(0, 0, TogglePaneButton.ActualWidth, TogglePaneButton.ActualHeight));
                TogglePaneButtonRect = rect;
            }
            else
            {
                TogglePaneButtonRect = new Rect();
            }

            TypedEventHandler <MainPage, Rect> handler = TogglePaneButtonRectChanged;

            // handler(this, this.TogglePaneButtonRect);
            handler?.DynamicInvoke(this, TogglePaneButtonRect);
        }
Пример #7
0
        /// <summary>
        ///     Initializes a new instance of the AppShell, sets the static 'Current' reference,
        ///     adds callbacks for Back requests and changes in the SplitView's DisplayMode, and
        ///     provide the nav menu list with the data to display.
        /// </summary>
        public AppShell()
        {
            InitializeComponent();

            Loaded += (sender, args) => {
                Current = this;

                TogglePaneButton.Focus(FocusState.Programmatic);
            };

            var currentView = SystemNavigationManager.GetForCurrentView();

            currentView.BackRequested    += SystemNavigationManager_BackRequested;
            NavMenuListTop.ItemsSource    = navlistTop;
            NavMenuListBottom.ItemsSource = navlistBottom;
            //start with the "accounts" navigation button selected
            NavMenuListTop.SelectedIndex = 0;
            //start with a hidden back button. This changes when you navigate to an other page
            currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
        }
Пример #8
0
        /// <summary>
        /// Check for the conditions where the navigation pane does not occupy the space under the floating
        /// hamburger button and trigger the event.
        /// </summary>
        private void CheckTogglePaneButtonSizeChanged()
        {
            if (RootSplitView.DisplayMode == SplitViewDisplayMode.Inline ||
                RootSplitView.DisplayMode == SplitViewDisplayMode.Overlay)
            {
                var transform = TogglePaneButton.TransformToVisual(this);
                var rect      = transform.TransformBounds(new Rect(0, 0, TogglePaneButton.ActualWidth, TogglePaneButton.ActualHeight));
                TogglePaneButtonRect = rect;
            }
            else
            {
                TogglePaneButtonRect = new Rect();
            }

            var handler = TogglePaneButtonRectChanged;

            if (handler != null)
            {
                // handler(this, this.TogglePaneButtonRect);
                handler.DynamicInvoke(this, TogglePaneButtonRect);
            }
        }
Пример #9
0
        /// <summary>
        ///     Check for the conditions where the navigation pane does not occupy the space under the floating
        ///     hamburger button and trigger the event.
        /// </summary>
        private void CheckTogglePaneButtonSizeChanged()
        {
            if (RootSplitView.DisplayMode == SplitViewDisplayMode.Inline ||
                RootSplitView.DisplayMode == SplitViewDisplayMode.Overlay ||
                RootSplitView.DisplayMode == SplitViewDisplayMode.CompactOverlay)
            {
                var transform = TogglePaneButton.TransformToVisual(this);
                var rect      =
                    transform.TransformBounds(new Rect(0, 0, TogglePaneButton.ActualWidth, TogglePaneButton.ActualHeight));
                TogglePaneButtonRect = rect;
            }
            else
            {
                TogglePaneButtonRect = new Rect();
            }

            if (RootSplitView.DisplayMode == SplitViewDisplayMode.Overlay && !RootSplitView.IsPaneOpen &&
                !new SettingsManager(new WindowsUwpSettings()).IsDarkThemeSelected)
            {
                TogglePaneButton.Foreground =
                    (SolidColorBrush)Application.Current.Resources["SplitViewToggleButtonForegroundDark"];
            }
            else
            {
                TogglePaneButton.Foreground =
                    (SolidColorBrush)Application.Current.Resources["SplitViewToggleButtonForegroundLight"];
            }

            if (RootSplitView.DisplayMode == SplitViewDisplayMode.Overlay)
            {
                RootSplitView.IsPaneOpen = false;
            }

            var handler = TogglePaneButtonRectChanged;

            handler?.DynamicInvoke(this, TogglePaneButtonRect);
        }
Пример #10
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            MenuItemsScrollViewer          = (ScrollViewer)GetTemplateChild("MenuItemsScrollViewer");
            PaneContentGrid                = (Grid)GetTemplateChild("PaneContentGrid");
            RootSplitView                  = (SplitView)GetTemplateChild("RootSplitView");
            TopNavArea                     = ((StackPanel)GetTemplateChild("TopNavArea"));
            TopNavMenuItemsHost            = ((ItemsRepeater)GetTemplateChild("TopNavMenuItemsHost"));
            ContentPaneTopPadding          = (Grid)GetTemplateChild("ContentPaneTopPadding");
            PaneToggleButtonGrid           = (Grid)GetTemplateChild("PaneToggleButtonGrid");
            ButtonHolderGrid               = (Grid)GetTemplateChild("ButtonHolderGrid");
            ContentGrid                    = (Grid)GetTemplateChild("ContentGrid");
            NavigationViewBackButton       = (Button)GetTemplateChild("NavigationViewBackButton");
            TogglePaneButton               = (Button)GetTemplateChild("TogglePaneButton");
            NavigationViewCloseButton      = (Button)GetTemplateChild("NavigationViewCloseButton");
            PaneHeaderCloseButtonColumn    = (ColumnDefinition)GetTemplateChild("PaneHeaderCloseButtonColumn");
            PaneHeaderToggleButtonColumn   = (ColumnDefinition)GetTemplateChild("PaneHeaderToggleButtonColumn");
            PaneCustomContentBorder        = (ContentControl)GetTemplateChild("PaneCustomContentBorder");
            ItemsContainerRow              = (RowDefinition)GetTemplateChild("ItemsContainerRow");
            PaneContentGridToggleButtonRow = (RowDefinition)GetTemplateChild("PaneContentGridToggleButtonRow");
            PaneHeaderContentBorderRow     = (RowDefinition)GetTemplateChild("PaneHeaderContentBorderRow");

            UpdateNavigationBackButtonSize();
            UpdateNavigationViewContentMargin();
            UpdateNavigationViewBackButtonMargin();
            UpdateNavigationViewButtonHolderGridMargin();
            OnApplyTemplateCore();
            OnApplyTemplateFinished?.Invoke(this, EventArgs.Empty);

            TogglePaneButton.RegisterPropertyChangedCallback(Button.HeightProperty, (_, __) => UpdatePaneToggleButtonSize());
            TogglePaneButton.RegisterPropertyChangedCallback(Button.WidthProperty, (_, __) => UpdatePaneToggleButtonSize());

            NavigationViewBackButton.RegisterPropertyChangedCallback(Button.HeightProperty, (_, __) => UpdateNavigationBackButtonSize());
            NavigationViewBackButton.RegisterPropertyChangedCallback(Button.WidthProperty, (_, __) => UpdateNavigationBackButtonSize());

            NavigationViewCloseButton.RegisterPropertyChangedCallback(Button.HeightProperty, (_, __) => UpdateNavigationBackButtonSize());
            NavigationViewCloseButton.RegisterPropertyChangedCallback(Button.WidthProperty, (_, __) => UpdateNavigationBackButtonSize());


            // These columns create a left padding on the PaneHeader
            // So this code just removes that padding
            PaneHeaderCloseButtonColumn.RegisterPropertyChangedCallback(ColumnDefinition.WidthProperty, (_, __) => PaneHeaderCloseButtonColumn.Width   = new WGridLength(0));
            PaneHeaderToggleButtonColumn.RegisterPropertyChangedCallback(ColumnDefinition.WidthProperty, (_, __) => PaneHeaderToggleButtonColumn.Width = new WGridLength(0));
            PaneHeaderToggleButtonColumn.Width = new WGridLength(0);
            PaneHeaderCloseButtonColumn.Width  = new WGridLength(0);

            // When the NavigationView is in locked mode the min height on the PaneHeader row gets set to 40
            // Which creates space between the title bar and the top of the flyout content
            PaneContentGridToggleButtonRow.MinHeight = 0;
            PaneContentGridToggleButtonRow.RegisterPropertyChangedCallback(RowDefinition.MinHeightProperty, (_, __) =>
                                                                           PaneContentGridToggleButtonRow.MinHeight = 0);

            PaneHeaderContentBorderRow.MinHeight = 0;
            PaneHeaderContentBorderRow.RegisterPropertyChangedCallback(RowDefinition.MinHeightProperty, (_, __) =>
                                                                       PaneHeaderContentBorderRow.MinHeight = 0);


            // WinUI has this set to -1,3,-1,3 but I'm not really sure why
            // It causes the content to not be flush up against the title bar
            PaneContentGrid.Margin = new WThickness(-1, 0, -1, 0);
            UpdateMenuItemsContainerHeight();
        }