代码之家  ›  专栏  ›  技术社区  ›  zhrnz

不聚焦时保留自定义标题栏颜色

  •  0
  • zhrnz  · 技术社区  · 10 年前

    我有一个带有自定义标题栏背景的UWP应用程序&前景色。它工作得很好,除非当应用程序没有对焦时,它会将标题栏变回原来的白色。

    public MainPage()
        {
            this.InitializeComponent();
    
            Windows.UI.ViewManagement.ApplicationViewTitleBar titleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;
            titleBar.BackgroundColor = Windows.UI.Colors.Black;
            titleBar.ForegroundColor = Windows.UI.Colors.White;
            titleBar.ButtonBackgroundColor = Windows.UI.Colors.Black;
            titleBar.ButtonForegroundColor = Windows.UI.Colors.White;     
        }
    

    即使应用程序没有对焦,我如何保持自定义标题栏的颜色?

    1 回复  |  直到 10 年前
        1
  •  2
  •   Justin XL    10 年前

    不活跃的 颜色。

    titleBar.InactiveBackgroundColor = titleBar.BackgroundColor = Windows.UI.Colors.Black;
    titleBar.InactiveForegroundColor = titleBar.ForegroundColor = Windows.UI.Colors.White;
    titleBar.ButtonInactiveBackgroundColor = titleBar.ButtonBackgroundColor = Windows.UI.Colors.Black;
    titleBar.ButtonInactiveForegroundColor = titleBar.ButtonForegroundColor = Windows.UI.Colors.White;
    

    这个 按钮 悬停 按下 颜色设置也是如此。

    enter image description here