Ejemplo n.º 1
0
 public HamburgerMenu()
 {
     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 = 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;
             }
         };
     }
 }
Ejemplo n.º 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) =>
                {
                    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;
                    }
                };
            }
        }
Ejemplo n.º 3
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);
                    }

                    if (!d.GetValue(e).Equals(IsOpen))
                    {
                        IsOpen = !IsOpen;
                    }
                });
                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;
                    }

                    if (NavButtonCount == 0)
                    {
                        _areNavButtonsLoaded = true;
                    }
                };
            }
        }