简体   繁体   English

如何设置xaml C#中所有windows的背景色?

[英]How to set the background color of all windows in xaml C#?

Is there an easy way to set the background color of all windows in app.xaml?有没有一种简单的方法可以在 app.xaml 中设置所有 windows 的背景颜色? I hope to set the default background color of windows in app.xaml.我希望在app.xaml中设置windows的默认背景色。 Please let me know how to set the background color of all windows in xaml.请告诉我如何设置 xaml 中所有 windows 的背景颜色。 Thanks in advance.提前致谢。

You can set default styles in App.xaml file like that:您可以在 App.xaml 文件中设置默认 styles ,如下所示:

<Application.Resources>
    <Style TargetType="{x:Type Window}">
        <Setter Property="Background" Value="Black" />
    </Style>
</Application.Resources>

TargetType is looking for specific type of element, For example Gird, Button, DockPanel TargetType正在寻找特定类型的元素,例如 Gird、Button、DockPanel

Property is specifying exact value you want to set属性指定您要设置的确切值

Value is the value itself价值就是价值本身

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

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