我有一个 Brush
对象,我想使用 Windows 窗体 ControlPaint.Light()
方法使它变亮。
我想将 System.Windows.Media.Brush
对象转换为 System.Drawing.Color
以便我可以将任何 XAML 按钮的背景颜色更改为其“浅色”单击按钮时的颜色",因为 System.Windows.Forms.ControlPaint.Light()
仅将颜色作为参数。
由于我的 Brush
对象不是 SolidColorBrush
,因此没有 Color
属性,是否有其他方法可以实现此目的?
最佳答案
试试这个:
Brush brush = Brushes.Yellow;
Color color = ((SolidColorBrush) brush).Color;
关于c# - 在 WPF 项目中调用 Winforms ControlPaint.Light(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21961920/