Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# how to convert system.windows.media.brush to system.drawing.brush

I am trying to add a watermark for a TextBox. The TextBox.Background is a System.Windows.Media.Brush. I need the Graphics.FillRectangle(System.Drawing.Brush....)

Is there any way to convert the mediea brush to the drawing brush?

like image 720
Payson Avatar asked Oct 24 '13 15:10

Payson


1 Answers

Try with this

System.Drawing.Brush b = new System.Drawing.SolidBrush((System.Drawing.Color)new System.Drawing.ColorConverter().ConvertFromString(new System.Windows.Media.BrushConverter().ConvertToString(mediabrush)));
like image 183
Sam Avatar answered Nov 12 '22 21:11

Sam