Move Toolbar to the bottom in UWP with PlatformConfiguration (Xamarin.Forms 2.3.3)

别等时光非礼了梦想. 提交于 2019-12-11 06:44:56

问题


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

回答1:


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

  • Toolbar Placement can only be set application wide, not per page
  • Toolbar Placement can only be set on a NavigationPage

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


来源:https://stackoverflow.com/questions/40484343/move-toolbar-to-the-bottom-in-uwp-with-platformconfiguration-xamarin-forms-2-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!