private void OnTogglePaneButton_Click(object sender, RoutedEventArgs e) { var closing = new NavigationViewPaneClosingEventArgs(); if (IsPaneOpen) { PaneClosing?.Invoke(this, closing); if (closing.Cancel) { this.Log().DebugIfEnabled(() => "Close pane canceled"); return; } } else { PaneOpening?.Invoke(this, null); } IsPaneOpen = !IsPaneOpen; if (IsPaneOpen) { PaneOpened?.Invoke(this, null); } else { PaneClosed?.Invoke(this, null); } }
/// <summary> /// DisplayModeStates /// ----------------- /// Closed /// ClosedCompactLeft /// ClosedCompactRight /// OpenOverlayLeft /// OpenOverlayRight /// OpenInlineLeft /// OpenInlineRight /// OpenCompactOverlayLeft /// OpenCompactOverlayRight /// </summary> private void UpdateVisualStates(bool useTransitons) { string stateName = GetStateName(); if (!IsPaneOpen) { PaneClosing?.Invoke(this, new SplitViewPaneClosingEventArgs()); } else { PaneOpening?.Invoke(this, null); } #if __IOS__ PatchInvalidFinalState(stateName); #endif VisualStateManager.GoToState(this, stateName, useTransitons); if (!IsPaneOpen) { PaneClosed?.Invoke(this, null); } else { PaneOpened?.Invoke(this, null); } }
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; } }
public void OpenInRightPane(string pageKey, NavigationParameters navigationParameters = null) { if (_rightPaneNavigationService.CanNavigate(pageKey)) { _rightPaneNavigationService.RequestNavigate(pageKey, navigationParameters); } _splitView.IsPaneOpen = true; PaneOpened?.Invoke(_splitView, EventArgs.Empty); }
private void RaisePaneOpenedOrClosedEvents() { // overall events if (IsOpen) { PaneOpened?.Invoke(ShellSplitView, EventArgs.Empty); } else { PaneClosed?.Invoke(ShellSplitView, EventArgs.Empty); } }
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; } }; } }
private void OnDisplayModeStatesCurrentStateChanged(object sender, VisualStateChangedEventArgs e) { _isDisplayModeStateChanging = false; if (_isPaneOpening) { _isPaneOpening = false; PaneOpened?.Invoke(this, null); } else if (_isPaneClosing) { _isPaneClosing = false; PaneClosed?.Invoke(this, null); } }
private void OpenPane() { if (_isPaneOpening) { return; } PaneOpening?.Invoke(this, null); if (UpdateDisplayModeState()) { _isPaneOpening = true; } else { PaneOpened?.Invoke(this, null); } }
public void OpenInRightPane(Type pageType, object parameter = null) { if (_frame.Content?.GetType() != pageType || (parameter != null && !parameter.Equals(_lastParameterUsed))) { var page = _serviceProvider.GetService(pageType) as Page; var navigated = _frame.Navigate(page, parameter); if (navigated) { _lastParameterUsed = parameter; if (_frame.Content is INavigationAware navigationAware) { navigationAware.OnNavigatedFrom(); } } } _splitView.IsPaneOpen = true; PaneOpened?.Invoke(_splitView, EventArgs.Empty); }
public void OpenInRightPane(string pageKey, object parameter = null) { var pageType = _pageService.GetPageType(pageKey); if (_frame.Content?.GetType() != pageType || (parameter != null && !parameter.Equals(_lastParameterUsed))) { var page = _pageService.GetPage(pageKey); var navigated = _frame.Navigate(page, parameter); if (navigated) { _lastParameterUsed = parameter; var dataContext = _frame.GetDataContext(); if (dataContext is INavigationAware navigationAware) { navigationAware.OnNavigatedFrom(); } } } _splitView.IsPaneOpen = true; PaneOpened?.Invoke(_splitView, EventArgs.Empty); }
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; } }; } }
/// <summary> /// Raises the <see cref="PaneOpened"/> event. /// </summary> protected virtual void OnPaneOpened() { PaneOpened?.Invoke(this, EventArgs.Empty); }