c# - UWP : styling the window buttons does not work on the close button

标签 c# .net win-universal-app

在 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 buttons _

有人知道问题出在哪里吗?是错误还是我做错了什么?

提前致谢!
-西蒙

最佳答案

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

关于c# - UWP : styling the window buttons does not work on the close button,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30244197/

相关文章:

c# - 取消阻止 AcceptTcpClient 调用

c# - 自动完成框 - 总体值不一致

c# - 正则表达式来获取样本的特定部分

.net - 使用其他 DLL 的 PInvoke DLL - ClickOnce 问题

.net - 使用 silverlight 和 wcf 测试 ssl

c# - Windows(手机)8.1 相机使用

c# - c#中没有变量的拉丁名称

c# - 更新绑定(bind)到 dataSet dataTable 的 listView,它从 SQL c# wpf 中查找数据

c# - 从 ContentDialog 导航到页面

c# - 如何将屏幕截图上传到 Microsoft Store for Windows 8.1 Universal App