简体   繁体   English

Visual Studio WPF设计器不使用覆盖的SystemColors

[英]Visual Studio WPF Designer does not use overwritten SystemColors

I am currently trying to overwrite the WPF system colors. 我目前正在尝试覆盖WPF系统颜色。 From here I found out that this can be done by creating a new SolidColorBrush resource with for example the key x:Key="{x:Static SystemColors.WindowBrushKey}" to change the Window's background color. 这里,我发现可以通过创建新的SolidColorBrush资源(例如,使用键x:Key="{x:Static SystemColors.WindowBrushKey}"来更改Window的背景色来完成此操作。

This already works however the Visual Studio WPF Designer does not show the new color as background of the Window. 这已经可以工作,但是Visual Studio WPF设计器不会将新颜色显示为窗口的背景。

Starting with a clean WPF App this is what my XAML code looks like for the MainWindow: 从一个干净的WPF应用程序开始,这就是MainWindow的XAML代码:

<Window x:Class="TestOverwriteSystemColor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TestOverwriteSystemColor"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="Orange" />
    </Window.Resources>
    <Grid>

    </Grid>
</Window>

In the Visual Studio Designer this looks like this: 在Visual Studio设计器中,如下所示:

Visual Studio WPF设计器视图

And that is the resulting application if I run it: 这就是如果我运行它的结果应用程序:

在此处输入图片说明

Also adding the SolidColorBrush Resource to the App.xaml resource does not change this. SolidColorBrush资源添加到App.xaml资源不会更改此设置。 What am I missing that the newly defined SystemColor is also used in the Designer? 我错过了在Designer中还使用了新定义的SystemColor吗?

As Otiel mentioned this probably is a bug in Visual Studio, so I started a problem report at Microsoft. 正如Otiel提到的那样,这可能是Visual Studio中的错误,因此我在Microsoft启动了问题报告。 For now it is Under Consideration: https://developercommunity.visualstudio.com/content/problem/633508/overwriting-resource-windowbrushkey-does-not-have.html 目前,它正在考虑中: https : //developercommunity.visualstudio.com/content/problem/633508/overwriting-resource-windowbrushkey-does-not-have.html

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

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