【发布时间】:2014-06-25 02:56:36
【问题描述】:
在 windows phone 8 中,添加和管理应用栏非常容易,但现在我测试新的 windows phone 8.1 SDK 以构建具有新地理围栏功能的项目,但我不知道如何添加应用栏应用程序。
【问题讨论】:
标签: .net mobile windows-phone-8 windows-phone windows-phone-8.1
在 windows phone 8 中,添加和管理应用栏非常容易,但现在我测试新的 windows phone 8.1 SDK 以构建具有新地理围栏功能的项目,但我不知道如何添加应用栏应用程序。
【问题讨论】:
标签: .net mobile windows-phone-8 windows-phone windows-phone-8.1
在Windows Phone 8.1 中,我们可以使用BottomAppBar 来添加App Bar。通常我们使用CommandBar 来创建基本的BottomAppBar。 CommandBar 包含两个集合:PrimaryCommands 和 SecondaryCommands,与 Windows Phone 8 中的 shell:ApplicationBar.Buttons 和 shell:ApplicationBar.MenuItems 类似。
请阅读这个演示,我们创建了一个带有两个按钮的 CommandBar:ZoomOut 和 ZoomIn,以及两个 menuItem:Test01 和 Test02:
<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>
编辑:现在代码是正确的!
【讨论】:
IsSticky 在 WP 8.1 上没有任何作用
这是另一种方式。之后一直滚动到 XAML 的顶部,单击第一个文本/字符串 <phone:PhoneApplicationPage 您可以按 F4 以调出“通用”选项,或者您可以单击它并转到属性和按“Common”,您将看到一个名为“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);
【讨论】: