【问题标题】:UWP Load a Page Into A FrameUWP 将页面加载到框架中
【发布时间】:2019-05-14 08:56:30
【问题描述】:

这是我第一次创建Win10 UWP程序。我有一个带有导航视图和框架的页面。 NavigationView 是一个供选择的列表程序。当用户单击其中一个选项时,相应的页面将加载到框架区域中。我尝试下面显示的代码,但是当我单击该项目并加载相应的页面时,该页面将填满整个窗口,而不是仅显示在框架区域中。它导致用户无法从 NavigationView 中选择其他选项。我该如何解决这个问题?

非常感谢!

<Page ...>
    <Grid>
        <NavigationView PaneDisplayMode="Left">
            <NavigationViewItem Content="Item 1" Name="NavigationItem1" />
            ...  // More items here
        </NavigationView>
        <ScrollViewer>
            <Frame Name="ContentFrame"></Frame>
        </ScrollViewer>
    </Grid>
</Page>

在 C# 中

private NavigationItem1_Tapped(object sender, TappedRoutedEventargs e)
{
    ContentFrame.Navigate(typeof(Page_1));
    // Page_1 is a Page Object created in the project
}

【问题讨论】:

    标签: c# uwp


    【解决方案1】:

    ScrollViewer 放在NavigationView 元素内:

    <Page ...>
        <Grid>
            <NavigationView PaneDisplayMode="Left">
                <NavigationView.MenuItems>
                    <NavigationViewItem Content="Item 1" Name="NavigationItem1" />
                </NavigationView.MenuItems>
                <ScrollViewer>
                    <Frame Name="ContentFrame"></Frame>
                </ScrollViewer>
            </NavigationView>
        </Grid>
    </Page>
    

    Using the NavigationView in your UWP applications

    【讨论】:

    • 这应该可以正常工作,但我建议删除不需要的ScrollViewerFrame 控件将在必要时滚动内容)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-22
    • 1970-01-01
    • 2010-12-06
    相关资源
    最近更新 更多