问题
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