gpt4 book ai didi

WPF 窗口背景颜色

转载 作者:行者123 更新时间:2023-12-01 19:30:19 25 4
gpt4 key购买 nike

默认情况下,wpf 窗口为白色。所以我应该为背景指定什么颜色,这样它看起来就像普通窗口,就像 .net 2.0 win 应用程序窗口颜色一样。请帮忙

最佳答案

您需要使用系统颜色画笔绘制背景。

SystemColors.ControlBrushKey property 将返回相应 SolidColorBrushResourceKey .

例如,要设置按钮的背景,您可以使用以下代码:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="SystemColors Example" Background="White">
<StackPanel Margin="20">
<Button
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
Content="Hello, World!" />
</StackPanel>
</Page>

关于WPF 窗口背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4968562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com