如何在 C# 文件中为 BottomAppBar WP8.1 指定 Minimized/Compact 模式

How to specify Minimized/Compact Mode for BottomAppBar WP8.1 in C# file

如何在 C# 文件中为 BottomAppBar WP8.1 指定 Minimized/Compact 模式?

我认为是设置 CommandBar.ClosedDisplayMode 属性,但如何设置?

为 CommandBar 分配一个变量,然后将 属性 设置为正常:

您可以在 Xaml:

中为变量分配 x:Name
<Page.BottomAppBar>
    <CommandBar x:Name="cmdBar">
    </CommandBar>
</Page.BottomAppBar>

或者您可以从您后面代码中的页面中找到它:

CommandBar cmdBar = Page.BottomAppBar as CommandBar;

两种方式:

cmdBar.ClosedDisplayMode = AppBarClosedDisplayMode.Compact;