繁体   English   中英

UWP:窗口按钮的样式在关闭按钮上不起作用

[英]UWP: styling the window buttons does not work on the close button

在Windows 10 UWP中,我们可以设置标题栏和窗口按钮(windows chrome)的样式。 但是,当使用悬停或单击它们时,这对关闭按钮不起作用。 请看以下代码段:

        Color PrimaryColor = Color.FromArgb( 0xFF, 0xFF, 0x00, 0x00 );
        Color ContrastColor = Color.FromArgb( 0xFF, 0x00, 0x00, 0x00 );
        Color SemiColor = Color.FromArgb( 0xFF, 0x7F, 0x00, 0x00 );

        ApplicationView AppView = ApplicationView.GetForCurrentView();

        AppView.TitleBar.ButtonInactiveBackgroundColor = ContrastColor;
        AppView.TitleBar.ButtonInactiveForegroundColor = PrimaryColor;
        AppView.TitleBar.ButtonBackgroundColor = ContrastColor;
        AppView.TitleBar.ButtonForegroundColor = PrimaryColor;

        AppView.TitleBar.ButtonHoverBackgroundColor = PrimaryColor;
        AppView.TitleBar.ButtonHoverForegroundColor = ContrastColor;

        AppView.TitleBar.ButtonPressedBackgroundColor = SemiColor;
        AppView.TitleBar.ButtonPressedForegroundColor = ContrastColor;

这应该使所有按钮变黑,并带有红色前景(图标)。 按下时应使用半红色背景。
它可以完美地用于最小和最大按钮 - 在关闭按钮上只有背景和前景(以及它的非活动版本)才能正确显示。 悬停和按下状态回退到默认窗口值。

请参阅下图。 关闭按钮有另一个红色(默认值)和悬停时的默认白色前景。

TitleBar按钮 _

有谁知道问题是什么? 这是一个错误还是我做错了什么?

提前致谢!
-Simon

你做得对,这就是现在的样子。 请记住,他们仍在根据用户反馈更改标题栏样式,因此可能会发生变化。 如果您想要更多地控制标题栏的某些方面,请考虑使用CoreApplicationViewTitleBar.ExtendViewIntoTitleBar属性构建完全自定义的标题栏。 但不确定它是否能解决这个具体问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM