简体   繁体   English

在WPF应用程序中存储颜色

[英]Storing colors in WPF applications

I'm upgrading an old WinForms application to WPF and is wondering how to store a color in WPF? 我正在将旧的WinForms应用程序升级到WPF,并且想知道如何在WPF中存储颜色?

In Winforms I had: 在Winforms中,我有:

public System.Drawing.Color Color { get; set; }

But in WPF the Color-class doesn't exist. 但是在WPF中,颜色类不存在。 How do you achieve the same thing in WPF? 您如何在WPF中实现同一目标?

Thanks in advance! 提前致谢!

In WPF, You can use Color like this: 在WPF中,可以使用如下颜色

public System.Windows.Media.Color Color { get; set; }

And in WPF, we can use Brush to control Background, Foreground and so on.Usually we use SolidBrush: 在WPF中,我们可以使用Brush来控制Background,Foreground等,通常我们使用SolidBrush:

public System.Windows.Media.SolidColorBrush Brush { get; set; }

In WPF you use Brush instead of Color. 在WPF中,使用“画笔”代替“颜色”。 Read this for more information. 阅读以获得更多信息。

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

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