在Windows Phone 8中,添加和管理应用栏非常容易。但是,现在我正在测试新的Windows Phone 8.1 SDK以构建具有新地理围栏功能的项目,但我不知道如何在应用程序中添加应用栏。
BottomAppBar
添加应用栏。通常情况下,我们使用CommandBar
创建基本的BottomAppBar
。CommandBar包含两个集合:PrimaryCommands
和SecondaryCommands
,类似于Windows Phone 8中的shell:ApplicationBar.Buttons
和shell:ApplicationBar.MenuItems
。<Page.BottomAppBar>
<CommandBar IsSticky="True" x:Name="appBar">
<CommandBar.PrimaryCommands>
<AppBarButton Icon="ZoomOut" IsCompact="False" Label="ZoomOut"/>
<AppBarButton Icon="ZoomIn" IsCompact="False" Label="ZoomIn"/>
</CommandBar.PrimaryCommands>
<CommandBar.SecondaryCommands>
<AppBarButton Label="Test01"/>
<AppBarButton Label="Test02"/>
</CommandBar.SecondaryCommands>
</CommandBar>
</Page.BottomAppBar>
编辑:现在代码是正确的!
还有一种方法。滚动到XAML的顶部,然后单击第一个文本/字符串<phone:PhoneApplicationPage
,您可以按F4键以打开“常规”选择,或者只需单击该属性并转到“常规”并在那里看到一个新选项称为“ApplicationBar”。这种方法更好,您可以用这种方式创建一个全新的。
public static void AddNewAppBarinPage(Page myPage)
{
CommandBar cbar = new CommandBar { ClosedDisplayMode = AppBarClosedDisplayMode.Minimal };
AppBarButton appBarButton = new AppBarButton { Label = "Audio" };
cbar.PrimaryCommands.Add(appBarButton);
myPage.BottomAppBar = cbar;
}
AppBarCustom.AddNewAppBarinPage(this);
IsSticky
在 WP 8.1 上没有任何作用。 - mcont