void SplitViewIsPaneOpenChanged(DependencyProperty dp) { // 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 (ShellSplitView.IsPaneOpen) { PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty); HamburgerButtonGridWidth = (ShellSplitView.DisplayMode == SplitViewDisplayMode.CompactInline) ? PaneWidth : squareWidth; } else { PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty); } // this will keep the two properties in sync if (IsOpen != ShellSplitView.IsPaneOpen) { IsOpen = ShellSplitView.IsPaneOpen; } }
private void UpdateSecondaryButtonOrientation() { // secondary layout if (SecondaryButtonOrientation.Equals(Orientation.Horizontal) && IsOpen) { _SecondaryButtonStackPanel.Orientation = Orientation.Horizontal; } else { _SecondaryButtonStackPanel.Orientation = Orientation.Vertical; } }
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; } }; } }
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; } }; } }
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; } }; } }