使用PlatformConfiguration

使用PlatformConfiguration

本文介绍了使用PlatformConfiguration(Xamarin.Forms 2.3.3)将工具栏移动到UWP的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

Xamarin.Forms 2.3.3.166-pre4中尝试新的PlatformConfiguration,但是将工具栏移到UWP的底部只是不想工作.我在做什么错了?

Trying out the new PlatformConfiguration in Xamarin.Forms 2.3.3.166-pre4 but moving the Toolbar to the bottom on UWP just doesn't want to work. What am I doing wrong?

using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;

namespace FormsToolBarDemo
{
    public partial class MainPage:ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            this.On<Windows>().SetToolbarPlacement(ToolbarPlacement.Bottom);
        }
    }
}

推荐答案

好吧,尝试了SetToolbarPlacement(ToolbarPlacement.Bottom)的所有可能组合后,我发现了几件事:

Alright, after trying every possible combination of SetToolbarPlacement(ToolbarPlacement.Bottom), I found out a few things:

  • 只能在整个应用范围内设置工具栏放置位置,而不能在每个页面上设置
  • 只能在NavigationPage
  • 上设置工具栏放置
  • Toolbar Placement can only be set application wide, not per page
  • Toolbar Placement can only be set on a NavigationPage

所以您可以做的是,当您要将工具栏放置在底部时,可以通过将工具栏位置附加到AppMainPage属性上来在整个应用程序中进行设置.

So what you can do, when you want to place the toolbar at the bottom, you can set it application wide by attaching the Toolbar Placement to the App classes MainPage property.

public App()
{
    MainPage = new NavigationPage(new MainPage());
    MainPage.On<Windows>().SetToolbarPlacement(ToolbarPlacement.Bottom);
}

这篇关于使用PlatformConfiguration(Xamarin.Forms 2.3.3)将工具栏移动到UWP的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:58