首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Windows 10 Mobile上处理底部导航栏

问在Windows 10 Mobile上处理底部导航栏
EN

Stack Overflow用户
提问于 2016-03-23 15:43:23
回答 2查看 959关注 0票数 0

在我的Xamarin.Forms应用程序中,底部有一个按钮。此按钮隐藏在Windows 10移动电话上。难道没有一个设置是我的页面大小适应可用的大小吗?在这种情况下,如果显示导航条,我的页面的高度会降低,如果导航栏被隐藏,则会增加。

我看到了一些解决方案,建议将导航栏隐藏起来。例如。

代码语言:javascript
复制
ApplicationView.GetForCurrentView().TryEnterFullScreenMode();

它应该放在哪里?我把它放在App.xaml.cs之前,rootFrame.Navigate放在OnLaunched里。如果我在本地机器上运行这个应用程序,它就会变成全屏。在手机上,导航栏是隐藏的,但底部还有一个白色的区域。

而且我试过了

代码语言:javascript
复制
ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Minimal;

但我没看到什么不同的东西。

开发人员应该如何处理导航栏而不隐藏其下面的内容?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-24 12:15:31

这似乎解决了这个问题:

代码语言:javascript
复制
ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;

结果是,在启动应用程序时,导航栏没有显示。用户可以通过滑动显示导航条。在这里,页面会根据需要自动调整大小。

我把它放在App.xaml.cs中的OnLaunched方法中:

代码语言:javascript
复制
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    Frame rootFrame = Window.Current.Content as Frame;

    // Do not repeat app initialization when the Window already has content,
    // just ensure that the window is active
    if (rootFrame == null)
    {
        // Create a Frame to act as the navigation context and navigate to the first page
        rootFrame = new Frame();

        rootFrame.NavigationFailed += OnNavigationFailed;

        Xamarin.Forms.Forms.Init(e);

        if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
        {
            //TODO: Load state from previously suspended application
        }

        // Place the frame in the current Window
        Window.Current.Content = rootFrame;
    }

    if (rootFrame.Content == null)
    {
        // When the navigation stack isn't restored navigate to the first page,
        // configuring the new page by passing required information as a navigation
        // parameter
        ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;
        rootFrame.Navigate(typeof(MainPage), e.Arguments);
    }
    // Ensure the current window is active
    Window.Current.Activate();
}
票数 0
EN

Stack Overflow用户

发布于 2017-03-24 08:27:47

您还可以使用:

代码语言:javascript
复制
ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);

在UWP的App.xaml.cs文件中,onLauched函数如下所示:

代码语言:javascript
复制
protected override void OnLaunched(LaunchActivatedEventArgs e)
    {
        if (System.Diagnostics.Debugger.IsAttached)
        {
            this.DebugSettings.EnableFrameRateCounter = true;
        }

        Frame rootFrame = Window.Current.Content as Frame;

        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();

            rootFrame.NavigationFailed += OnNavigationFailed;

            Xamarin.Forms.Forms.Init(e);

            if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Place the frame in the current Window
            Window.Current.Content = rootFrame;
        }

        if (rootFrame.Content == null)
        {
            // When the navigation stack isn't restored navigate to the first page,
            // configuring the new page by passing required information as a navigation
            // parameter
            ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
            rootFrame.Navigate(typeof(MainPage), e.Arguments);
        }
        // Ensure the current window is active
        Window.Current.Activate();
    }

这将确保您的应用程序停留在可见区域内,因此没有覆盖从底部导航栏。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36182639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档