[英]Visual Studio WPF Designer does not use overwritten SystemColors
我目前正在尝试覆盖WPF系统颜色。 从这里,我发现可以通过创建新的SolidColorBrush资源(例如,使用键x:Key="{x:Static SystemColors.WindowBrushKey}"
来更改Window的背景色来完成此操作。
这已经可以工作,但是Visual Studio WPF设计器不会将新颜色显示为窗口的背景。
从一个干净的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>
在Visual Studio设计器中,如下所示:
这就是如果我运行它的结果应用程序:
SolidColorBrush
资源添加到App.xaml资源不会更改此设置。 我错过了在Designer中还使用了新定义的SystemColor吗?
正如Otiel提到的那样,这可能是Visual Studio中的错误,因此我在Microsoft启动了问题报告。 目前,它正在考虑中: https : //developercommunity.visualstudio.com/content/problem/633508/overwriting-resource-windowbrushkey-does-not-have.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.