Exemplo n.º 1
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");
            OnApplyTemplateCore();
            OnApplyTemplateFinished?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 2
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            AppTitleBar = (FrameworkElement)GetTemplateChild("AppTitleBar");
            AppFontIcon = (Image)GetTemplateChild("AppFontIcon");
            AppTitle    = (TextBlock)GetTemplateChild("AppTitle");

            OnApplyTemplateFinished?.Invoke(this, EventArgs.Empty);

            UpdateAppTitleBarMargins();

            AppFontIcon.ImageOpened += OnImageOpened;
            AppFontIcon.ImageFailed += OnImageFailed;
            SetWindowTitle(_windowTitle);
        }
Exemplo n.º 3
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();
        }