简体   繁体   English

C#如何将system.windows.media.brush转换为system.drawing.brush

[英]C# how to convert system.windows.media.brush to system.drawing.brush

I am trying to add a watermark for a TextBox. 我正在尝试为TextBox添加水印。 The TextBox.Background is a System.Windows.Media.Brush. TextBox.Background是一个System.Windows.Media.Brush。 I need the Graphics.FillRectangle(System.Drawing.Brush....) 我需要Graphics.FillRectangle(System.Drawing.Brush ....)

Is there any way to convert the mediea brush to the drawing brush? 有没有办法将mediea画笔转换为绘图画笔?

试试这个

System.Drawing.Brush b = new System.Drawing.SolidBrush((System.Drawing.Color)new System.Drawing.ColorConverter().ConvertFromString(new System.Windows.Media.BrushConverter().ConvertToString(mediabrush)));

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

相关问题 将System.Windows.Media.Brush转换为System.Drawing.Brush - Convert System.Windows.Media.Brush to System.Drawing.Brush 将BitmapImage转换为System.Windows.Media.Brush - Convert BitmapImage to System.Windows.Media.Brush 将system.windows.media.brush转换为Hex颜色代码 - Converting system.windows.media.brush to Hex color code 将Color作为#XXXXXX等字符串转换为System.Windows.Media.Brush的最简单方法 - Simpliest way to convert a Color as a string like #XXXXXX to System.Windows.Media.Brush System.Drawing.Crush来自System.Drawing.Color - System.Drawing.Brush from System.Drawing.Color 'ColorAnimation' 动画对象不能用于为属性 'Background' 设置动画,因为它是不兼容的类型 'System.Windows.Media.Brush' - 'ColorAnimation' animation object cannot be used to animate property 'Background' because it is of incompatible type 'System.Windows.Media.Brush' WPF无法将system.drawing.bitmap隐式转换为media.brush - WPF cannot implicitly convert system.drawing.bitmap to media.brush 如何在 C# 中将类型“system.windows.media.imagesource”转换为“system.drawing.image”或 byte[]? - How to convert type 'system.windows.media.imagesource' to 'system.drawing.image' or byte[] in C#? 如何序列化Windows.Media.Brush - How to serialize a Windows.Media.Brush C#-将对象转换为画笔(WPF) - C# - convert Object to Brush (WPF)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM