更改命令栏 (应用栏) 颜色

本文关键字:颜色 应用 命令 | 更新日期: 2023-09-27 17:56:23

我想更改命令栏Background的背景颜色并Foreground。但是,仅设置Background="whatever" Foreground="whatever"不会更改溢出部分。

我尝试了几个小时使用模板和样式等,但我真的不知道我在做什么,所以它没有用.我已经阅读了 https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/styling-controls 和 https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/control-templates(以及其他诸如本网站上的许多问题)的内容,它们实际上只是告诉您存在更改样式之类的事情,它们向您展示如何将元素设置为某种样式。但是它们不会向您显示哪些元素具有哪些可用变量...此外,当右键单击命令栏 - 编辑样式 - 编辑副本时 - 我得到的是一个空的,它会立即使命令栏不可见。这对我来说没有意义。

那么 - 如何更改命令栏的样式/模板?

更改命令栏 (应用栏) 颜色

这篇博文详细介绍了如何解决溢出问题:

https://metronuggets.com/2015/08/04/universal-windows-apps-appbars-and-custom-colours/

它涉及为溢出情况指定样式。

主要的魔力就在这里:

<Page.BottomAppBar>
    <CommandBar Background="Blue"
                Foreground="White">
        <CommandBar.CommandBarOverflowPresenterStyle>
            <Style TargetType="CommandBarOverflowPresenter">
                <Setter Property="Background"
                        Value="Blue" />
            </Style>
        </CommandBar.CommandBarOverflowPresenterStyle>
        <CommandBar.PrimaryCommands>
            <AppBarButton Label="settings"
                          Icon="Setting"
                          Foreground="White"/>
        </CommandBar.PrimaryCommands>
        <CommandBar.SecondaryCommands>
            <AppBarButton Label="about"
                          Foreground="White"/>
        </CommandBar.SecondaryCommands>
    </CommandBar>
</Page.BottomAppBar>