示例#1
0
        void HamburgerMenu_Loaded(object sender, RoutedEventArgs args)
        {
            DebugWrite();

            // splitview property changes
            ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) => SplitViewIsPaneOpenChanged(e));
            ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) => SplitViewDisplayModeChanged(e));
        }
示例#2
0
        public HamburgerMenu()
        {
            InitializeComponent();
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                // nothing
            }
            else
            {
                PrimaryButtons   = new ObservableItemCollection <HamburgerButtonInfo>();
                SecondaryButtons = new ObservableItemCollection <HamburgerButtonInfo>();
                KeyboardService.Instance.AfterWindowZGesture = () => { HamburgerCommand.Execute(null); };
                ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) =>
                {
                    // secondary layout
                    if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) &&
                        ShellSplitView.IsPaneOpen)
                    {
                        _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal;
                    }
                    else
                    {
                        _SecondaryButtonStackPanel.Orientation = Orientation.Vertical;
                    }

                    // overall events
                    if ((d as SplitView).IsPaneOpen)
                    {
                        PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty);
                        PaneOpen?.Invoke(ShellSplitView, EventArgs.Empty);
                    }
                    else
                    {
                        PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty);
                    }
                });
                ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) =>
                {
                    DisplayMode = ShellSplitView.DisplayMode;
                });
                Loaded += (s, e) =>
                {
                    var any = GetType().GetRuntimeProperties()
                              .Where(x => x.PropertyType == typeof(SolidColorBrush))
                              .Any(x => x.GetValue(this) != null);
                    if (!any)
                    {
                        // this is the default color if the user supplies none
                        AccentColor = Colors.DarkOrange;
                    }
                };
            }
        }
        void HamburgerMenu_Loaded(object sender, RoutedEventArgs args)
        {
            DebugWrite();

            // non-custom property changes
            ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) => SplitViewIsPaneOpenChanged(e));
            ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) => SplitViewDisplayModeChanged(e));
            RegisterPropertyChangedCallback(RequestedThemeProperty, (d, e) => RefreshStyles(RequestedTheme));

            // keyboard navigation
            HamburgerButton.KeyDown          += HamburgerMenu_KeyDown;
            PrimaryButtonContainer.KeyDown   += HamburgerMenu_KeyDown;
            SecondaryButtonContainer.KeyDown += HamburgerMenu_KeyDown;

            // initial styles
            RefreshStyles(RequestedTheme);
        }
示例#4
0
        private void HamburgerMenu_Loaded(object sender, RoutedEventArgs args)
        {
            DebugWrite();

            // non-custom property changes
            ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, SplitView_IsPaneOpenChanged);
            ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, SplitView_DisplayModeChanged);
            RegisterPropertyChangedCallback(RequestedThemeProperty, HamburgerMenu_RequestedThemeChanged);

            // keyboard navigation
            HamburgerButton.KeyDown          += HamburgerMenu_KeyDown;
            PrimaryButtonContainer.KeyDown   += HamburgerMenu_KeyDown;
            SecondaryButtonContainer.KeyDown += HamburgerMenu_KeyDown;

            // initial styles
            UpdateHamburgerButtonGridWidthToFillAnyGap();
            RefreshStyles(RequestedTheme);
            UpdatePaneMarginToShowHamburgerButton();
        }
示例#5
0
        private void HamburgerMenu_Loaded(object sender, RoutedEventArgs args)
        {
            // non-custom property changes
            ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, SplitView_IsPaneOpenChanged);
            ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, SplitView_DisplayModeChanged);
            RegisterPropertyChangedCallback(RequestedThemeProperty, HamburgerMenu_RequestedThemeChanged);

            // keyboard navigation
            HamburgerButton.KeyDown          += HamburgerMenu_KeyDown;
            PrimaryButtonContainer.KeyDown   += HamburgerMenu_KeyDown;
            SecondaryButtonContainer.KeyDown += HamburgerMenu_KeyDown;

            // initial styles
            UpdateHamburgerButtonGridWidthToFillAnyGap();
            RefreshStyles(RequestedTheme);
            UpdatePaneMarginToShowHamburgerButton();

            // Moved here from HamburgerMenu_LayoutUpdated because it was one-time event handler.
            // LayoutUpdated handler is not needed, Loaded is called after template applying anyway.
            UpdateVisualStates();
            UpdateControl();
        }
示例#6
0
 public HamburgerMenu()
 {
     this.InitializeComponent();
     if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
     {
         // nothing
     }
     else
     {
         PrimaryButtons   = new ObservableItemCollection <HamburgerButtonInfo>();
         SecondaryButtons = new ObservableItemCollection <HamburgerButtonInfo>();
         new KeyboardService().AfterWindowZGesture = () => { HamburgerCommand.Execute(null); };
         ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) =>
         {
             if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) && ShellSplitView.IsPaneOpen)
             {
                 _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal;
             }
             else
             {
                 _SecondaryButtonStackPanel.Orientation = Orientation.Vertical;
             }
         });
         ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) =>
         {
             DisplayMode = ShellSplitView.DisplayMode;
         });
         Loaded += (s, e) =>
         {
             var any = this.GetType().GetRuntimeProperties()
                       .Where(x => x.PropertyType == typeof(SolidColorBrush))
                       .Any(x => x.GetValue(this) != null);
             if (!any)
             {
                 AccentColor = Colors.DarkGreen;
             }
         };
     }
 }
示例#7
0
        public HamburgerMenu()
        {
            InitializeComponent();
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                // nothing
            }
            else
            {
                PrimaryButtons   = new ObservableItemCollection <HamburgerButtonInfo>();
                SecondaryButtons = new ObservableItemCollection <HamburgerButtonInfo>();
                KeyboardService.Instance.AfterWindowZGesture = () => { HamburgerCommand.Execute(null); };
                ShellSplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, (d, e) =>
                {
                    DebugWrite($"Current:{(d as SplitView).IsPaneOpen}");

                    // this can occur if the user resizes before it loads
                    if (_SecondaryButtonStackPanel == null)
                    {
                        return;
                    }

                    // secondary layout
                    if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) &&
                        ShellSplitView.IsPaneOpen)
                    {
                        _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal;
                    }
                    else
                    {
                        _SecondaryButtonStackPanel.Orientation = Orientation.Vertical;
                    }

                    // overall events
                    if ((d as SplitView).IsPaneOpen)
                    {
                        PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty);
                        PaneOpen?.Invoke(ShellSplitView, EventArgs.Empty);
                    }
                    else
                    {
                        PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty);
                    }

                    // this will keep the two properties in sync
                    if (!d.GetValue(e).Equals(IsOpen))
                    {
                        IsOpen = !IsOpen;
                    }
                });
                ShellSplitView.RegisterPropertyChangedCallback(SplitView.DisplayModeProperty, (d, e) =>
                {
                    DebugWrite($"Current:{ShellSplitView.DisplayMode}");

                    // this will keep the two properties in sync
                    DisplayMode = ShellSplitView.DisplayMode;
                });
                Loaded += (s, e) =>
                {
                    // look to see if any brush property has been set
                    var any = GetType().GetRuntimeProperties()
                              .Where(x => x.PropertyType == typeof(SolidColorBrush))
                              .Any(x => x.GetValue(this) != null);

                    // this is the default color if the user supplies none
                    if (!any)
                    {
                        AccentColor = (Color)Resources["SystemAccentColor"];
                    }

                    // in case the developer has defined zero buttons
                    if (NavButtonCount == 0)
                    {
                        _areNavButtonsLoaded = true;
                    }
                };
            }
        }