Visual Studio WPF Designer does not use overwritten SystemColors

391 views Asked by At

I am currently trying to overwrite the WPF system colors. 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.

This already works however the Visual Studio WPF Designer does not show the new color as background of the Window.

Starting with a clean WPF App this is what my XAML code looks like for the MainWindow:

<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 WPF Designer View

And that is the resulting application if I run it:

enter image description here

Also adding the SolidColorBrush Resource to the App.xaml resource does not change this. What am I missing that the newly defined SystemColor is also used in the Designer?

1

There are 1 answers

0
Kilian Hohm On

As Otiel mentioned this probably is a bug in Visual Studio, so I started a problem report at Microsoft. For now it is Under Consideration: https://developercommunity.visualstudio.com/content/problem/633508/overwriting-resource-windowbrushkey-does-not-have.html