如何让Windows手机上的AppBar以编程方式消失/出现?

时间:2014-11-06 17:58:15

标签: windows-phone-8.1

在Windows手机上,我可以在我的页面中声明App栏,如下所示:

 <Page.BottomAppBar>
    <CommandBar>
    ..
    </CommandBar>
 </Page.BottomAppBar>

我的问题是如何以编程方式让该应用栏消失并重新出现?

谢谢。

2 个答案:

答案 0 :(得分:1)

因此 IsOpen 属性打开/关闭AppBar(显示/隐藏二级菜单和标签),完全隐藏AppBar,我只是将 BottomAppBar 属性设置为null在记住变量中的旧条之后。然后,当我想要返回我的AppBar时,我使用该变量,示例代码:

CommandBar previousBar;
private void HideBar()
{
    previousBar = BottomAppBar as CommandBar;
    BottomAppBar = null;
}

private void ShowBar()
{
    BottomAppBar = previousBar;
}

答案 1 :(得分:0)

您可以通过编程方式by setting the IsOpen property打开和关闭应用栏。您可以通过处理已打开和已关闭的事件来响应正在打开或关闭的应用栏。

if (this.BottomAppBar != null)
{
    this.BottomAppBar.IsOpen = true;
}
相关问题