c# - 在 WPF 项目中调用 Winforms ControlPaint.Light()

标签 c# wpf winforms xaml colors

我有一个 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/

相关文章:

c# - C 夏普日期时间格式

wpf - 当鼠标悬停在图像按钮上时如何更改图像按钮的颜色?

c# - 如何自定义项目在 ComboBox 控件中的显示方式?

c# - 将关闭按钮(红色 x)添加到 .NET 工具提示

c# - 宽度和高度与屏幕像素不匹配

c# - ASP.NET Google Reporting API 值与 Google Analytics Dashboard 不同

c# - Windows Phone 8.1 媒体元素

c# - 如何隐藏 ScintillaNET 中的第一行?

c# - WPF 弹出窗口

wpf - 边框背景上的 Style.DataTrigger