private void OnModeChanged(WinUI.TwoPaneView twoPaneView) { if (twoPaneView.Mode == WinUI.TwoPaneViewMode.SinglePane) { TwoPanePriority = WinUI.TwoPaneViewPriority.Pane2; } }
private void MainView_ModeChanged(Microsoft.UI.Xaml.Controls.TwoPaneView sender, object args) { Microsoft.UI.Xaml.Controls.TwoPaneViewMode theMode = sender.Mode; Debug.WriteLine(string.Format("MinWideModeWidth is {0}", MainView.MinWideModeWidth)); Debug.WriteLine(string.Format("MinTallModeHeight is {0}", MainView.MinTallModeHeight)); double minWideModeWidth = MainView.MinWideModeWidth; double minTallModeHeight = MainView.MinTallModeHeight; double windowWidth = Window.Current.Bounds.Width; double windowHeight = Window.Current.Bounds.Height; if (windowWidth > minWideModeWidth) { Debug.WriteLine("Window width > minWideModeWidth, should be in Wide mode"); } else if (windowWidth < minWideModeWidth && windowHeight > minTallModeHeight) { Debug.WriteLine("Window width < minWideModeWidth && windowHeight > minTallModeHeight, should be in Tall mode"); } else if (windowWidth < minWideModeWidth && windowHeight < minTallModeHeight) { Debug.WriteLine("Window width < minWideModeWidth && windowHeight < minTallModeHeight, should be in Single Pane mode"); } else { Debug.WriteLine("Can't compute mode"); } switch (theMode) { case MUXC.TwoPaneViewMode.SinglePane: // Debug.WriteLine("MainView_ModeChanged TwoPaneView Mode is SinglePane"); break; case MUXC.TwoPaneViewMode.Tall: // Debug.WriteLine("MainView_ModeChanged TwoPaneView Mode is Tall"); break; case MUXC.TwoPaneViewMode.Wide: // Debug.WriteLine("MainView_ModeChanged TwoPaneView Mode is Wide"); break; default: // break; } Debug.WriteLine(string.Format("TwoPaneView.Pane1Lenth = {0}, Pane2Length = {1}", MainView.Pane1Length, MainView.Pane2Length)); }
private void OnModeChanged(WinUI.TwoPaneView twoPaneView) { if (twoPaneView.Mode == WinUI.TwoPaneViewMode.SinglePane) { OnPageCanGoBackChanged?.Invoke(this, true); TwoPanePriority = WinUI.TwoPaneViewPriority.Pane2; } else { OnPageCanGoBackChanged?.Invoke(this, false); TwoPanePriority = WinUI.TwoPaneViewPriority.Pane1; } }
/// <summary> /// STEP 2.2: Detail page code-behind /// This fires when the TwoPaneViewMode (SinglePane, Wide & Tall) is changed. /// /// Here we set the PlanTripTop button on the top right to be visible in Tall mode, /// so users don't need to scroll down to the content to make the same action. /// </summary> private void OnContentViewModeChanged(WinUI.TwoPaneView sender, object args) { switch (sender.Mode) { // Update layout when two Panes are stacked horizontally. case WinUI.TwoPaneViewMode.Wide: PlanTripTop.Visibility = Visibility.Collapsed; break; // Update layout when two Panes are stacked vertically. case WinUI.TwoPaneViewMode.Tall: PlanTripTop.Visibility = Visibility.Visible; break; } }
/// <summary> /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call /// ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays /// in your app. Override this method to influence the default post-template logic of a class. /// </summary> protected override void OnApplyTemplate() { base.OnApplyTemplate(); if (_inlineBackButton != null) { _inlineBackButton.Click -= OnInlineBackButtonClicked; } _inlineBackButton = (Button)GetTemplateChild(PartBackButton); if (_inlineBackButton != null) { _inlineBackButton.Click += OnInlineBackButtonClicked; } _selectionStateGroup = (VisualStateGroup)GetTemplateChild(SelectionStates); if (_selectionStateGroup != null) { _selectionStateGroup.CurrentStateChanged += OnSelectionStateChanged; } _twoPaneView = (NavigationView.TwoPaneView)GetTemplateChild(PartRootPanel); if (_twoPaneView != null) { _twoPaneView.ModeChanged += OnModeChanged; } _detailsPresenter = (ContentPresenter)GetTemplateChild(PartDetailsPresenter); SetDetailsContent(); SetListHeaderVisibility(); OnDetailsCommandBarChanged(); OnListCommandBarChanged(); OnListPaneWidthChanged(); UpdateView(true); }
/// <summary> /// Used for debugging. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void MainView_ModeChanged(MUXC.TwoPaneView sender, object args) { switch (sender.Mode) { case MUXC.TwoPaneViewMode.SinglePane: // Debug.WriteLine("MainView_ModeChanged TwoPaneView Mode is SinglePane"); break; case MUXC.TwoPaneViewMode.Tall: // Debug.WriteLine("MainView_ModeChanged TwoPaneView Mode is Tall"); break; case MUXC.TwoPaneViewMode.Wide: // Debug.WriteLine("MainView_ModeChanged TwoPaneView Mode is Wide"); break; default: // break; } }
public void Initialize(WinUI.TwoPaneView twoPaneView) { _twoPaneView = twoPaneView; }
/// <summary> /// Fired when the <see cref="TwoPaneView"/> changed its view mode. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The event args.</param> private void OnModeChanged(NavigationView.TwoPaneView sender, object args) { UpdateView(true); SetListSelectionWithKeyboardFocusOnVisualStateChanged(ViewState); }