0

我在通用 Windows 应用程序中创建了带有汉堡菜单的 page1。我想在新屏幕中打开 page2 而不是在 page1 中显示 page2。

这是我的xml:

<Page x:Class="Hamburger_Menu.MainPage"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:local="using:Hamburger_Menu"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:triggers="using:WindowsStateTriggers"
          mc:Ignorable="d"
          DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=MainViewModel}">

        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup>
                    <VisualState>
                        <VisualState.StateTriggers>
                            <AdaptiveTrigger MinWindowWidth="1300" />
                        </VisualState.StateTriggers>
                        <VisualState.Setters>
                            <Setter Target="NavigationPane.DisplayMode"
                                    Value="CompactOverlay" />
                        </VisualState.Setters>
                    </VisualState>
                    <VisualState>
                        <VisualState.StateTriggers>
                            <AdaptiveTrigger MinWindowWidth="720" />
                        </VisualState.StateTriggers>
                        <VisualState.Setters>
                            <Setter Target="NavigationPane.DisplayMode"
                                    Value="CompactOverlay" />
                        </VisualState.Setters>
                    </VisualState>
                    <VisualState>
                        <VisualState.StateTriggers>
                            <AdaptiveTrigger MinWindowWidth="0" />
                        </VisualState.StateTriggers>
                        <VisualState.Setters>
                            <Setter Target="NavigationPane.DisplayMode"
                                    Value="Overlay" />
                        </VisualState.Setters>
                    </VisualState>
                    <VisualState>
                        <VisualState.StateTriggers>
                            <triggers:DeviceFamilyStateTrigger DeviceFamily="Mobile" />
                        </VisualState.StateTriggers>
                        <VisualState.Setters>
                            <Setter Target="NavigationPane.DisplayMode"
                                    Value="Overlay" />
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

            <Grid.RowDefinitions>
                <RowDefinition Height="48" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <ToggleButton x:Name="TogglePaneButton"
                              TabIndex="1"
                              Background="#990000"
                              Style="{StaticResource SplitViewTogglePaneButtonStyle}"
                              IsChecked="{Binding IsPaneOpen, ElementName=NavigationPane, Mode=TwoWay}"
                              AutomationProperties.Name="Menu"
                              ToolTipService.ToolTip="Menu" />

                <Grid Grid.Column="1"
                      Background="#990000">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock FontSize="20"
                               Margin="10,11,0,10"
                               Foreground="White"
                               VerticalAlignment="Center"
                               HorizontalAlignment="Left"
                               Text="{Binding SelectedMenuItem.Title}" Grid.RowSpan="2" />
                </Grid>

            </Grid>

            <SplitView x:Name="NavigationPane"
                       Grid.Row="1"
                       OpenPaneLength="215"
                       CompactPaneLength="48"
                       DisplayMode="Inline"
                       IsPaneOpen="False">
                <SplitView.Pane>

                    <ListView x:Name="LeftMenu"
                              Grid.Row="1"
                              Background="{StaticResource MenuBGColorBrush}"
                              ItemContainerStyle="{StaticResource MenuListViewItem}"
                              ItemsSource="{Binding MenuItems}"
                              SelectedItem="{Binding SelectedMenuItem,Mode=TwoWay}">

                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <Grid x:Name="MenuGrid"
                                      Margin="0"
                                      Tapped="MenuGrid_Tapped"
                                      Background="Transparent">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="48" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <Grid Grid.Row="0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="48" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>

                                        <SymbolIcon Symbol="{Binding SymbolIcon}"
                                                    Grid.Column="0"
                                                    VerticalAlignment="Center"
                                                    HorizontalAlignment="Center"
                                                    ToolTipService.ToolTip="{Binding Title}" />

                                        <TextBlock Grid.Column="1"
                                                   VerticalAlignment="Center"
                                                   Text="{Binding Title}"
                                                   Margin="10,0,0,0"
                                                   FontSize="16"
                                                   TextTrimming="CharacterEllipsis" />

                                    </Grid>

                                    <Border Grid.Row="1"
                                            BorderBrush="#33415B"
                                            Height="2"
                                            Margin="0"
                                            VerticalAlignment="Bottom"
                                            BorderThickness="0,0,0,1" />
                                </Grid>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

                </SplitView.Pane>
                <SplitView.Content>

                    <Frame x:Name="FrameContent">
                        <Frame.ContentTransitions>
                            <TransitionCollection>
                                <NavigationThemeTransition>
                                    <NavigationThemeTransition.DefaultNavigationTransitionInfo>
                                        <EntranceNavigationTransitionInfo />
                                    </NavigationThemeTransition.DefaultNavigationTransitionInfo>
                                </NavigationThemeTransition>
                            </TransitionCollection>
                        </Frame.ContentTransitions>
                    </Frame>

                </SplitView.Content>
            </SplitView>
        </Grid>
    </Page>

屏幕1: 在此处输入图像描述

屏幕2:在此处输入图像描述

屏幕3:在此处输入图像描述

当我从 Page1 中选择获取报价按钮时,我想在新屏幕中打开一个 page2 作为第三个屏幕,但 page2 显示在 Page1 上,因为 screen2(即) page2 仅显示在 page1 内。

我使用以下代码从 page1 导航到 page3,

this.Frame.Navigate(typeof(GetQuotes));

提前感谢您的回复。

4

0 回答 0