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

时间:2016-03-23 15:43:23

标签: xamarin win-universal-app xamarin.forms navigationbar windows-10-mobile

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

我看到解决方案建议以编程方式隐藏导航栏。 E.g。

ApplicationView.GetForCurrentView().TryEnterFullScreenMode();

它应该放在哪里?我将其放在App.xaml.cs rootFrame.Navigate OnLaunched之内ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Minimal; 。如果我在本地计算机上运行该应用程序,则会更改为全屏。在手机上隐藏了导航栏,但底部仍然有一个白色区域。

此外我试过

input <- c(1,1,1,2)
n <- 4
increment <- 2
sort(rep.int(seq.int(from = 0, by = increment, length.out = n), length(input))) + input

[1] 1 1 1 2 3 3 3 4 5 5 5 6 7 7 7 8

但我没有看到不同的东西。

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

2 个答案:

答案 0 :(得分:0)

这似乎解决了这个问题:

ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;

结果是启动应用程序时未显示导航栏。用户可以通过向上滑动显示导航栏。此处页面会根据需要自动调整大小。

我将其放在App.xaml.cs方法的OnLaunched中:

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();
}

答案 1 :(得分:0)

您也可以使用:

ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);

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

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();
    }

这将确保您的应用停留在可见区域内,因此底部导航栏没有叠加。