Skip to main content
 首页 » 编程设计

c#之在 WPF 应用程序中存储颜色

2024年02月06日12dflying

我正在将旧的 WinForms 应用程序升级到 WPF,并且想知道如何在 WPF 中存储颜色?

在 Winforms 中我有:

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

但在 WPF 中,颜色类不存在。你如何在 WPF 中实现同样的事情?

提前致谢!

请您参考如下方法:

在 WPF 中,您可以像这样使用 Color:

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

而在WPF中,我们可以使用Brush来控制Background、Foreground等。通常我们使用SolidBrush:

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