Windows 上的页面工具栏布局Page Toolbar Placement on Windows

下载示例 下载示例Download Sample Download the sample

此通用 Windows 平台平台特定用于更改工具栏在上Page的位置, 并通过Page.ToolbarPlacement将附加属性设置ToolbarPlacement为枚举的值来在 XAML 中使用:This Universal Windows Platform platform-specific is used to change the placement of a toolbar on a Page, and is consumed in XAML by setting the Page.ToolbarPlacement attached property to a value of the ToolbarPlacement enumeration:

<TabbedPage ...
            xmlns:windows="clr-namespace:Xamarin.Forms.PlatformConfiguration.WindowsSpecific;assembly=Xamarin.Forms.Core"
            windows:Page.ToolbarPlacement="Bottom">
  ...
</TabbedPage>

或者,可以使用它从 C# 使用 fluent API:Alternatively, it can be consumed from C# using the fluent API:

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

page.On<Windows>().SetToolbarPlacement(ToolbarPlacement.Bottom);

Page.On<Windows>方法指定仅将在 Windows 上运行此特定于平台的。The Page.On<Windows> method specifies that this platform-specific will only run on Windows. Page.SetToolbarPlacement 方法,在 Xamarin.Forms.PlatformConfiguration.WindowsSpecific 命名空间,用于通过设置工具栏位置 ToolbarPlacement 枚举提供三个值: Default Top ,以及 Bottom The Page.SetToolbarPlacement method, in the Xamarin.Forms.PlatformConfiguration.WindowsSpecific namespace, is used to set the toolbar placement, with the ToolbarPlacement enumeration providing three values: Default, Top, and Bottom.

结果是,为应用指定的工具栏放置 Page 实例:The result is that the specified toolbar placement is applied to the Page instance: