# .NET and More > WPF, WCF, WF >  VB.NET color to WPF color

## henrikl

Hi,
How do I set a color in my WPF (System.Windows.Media.Color) from VB.NET
I get an error : Value of type System.Drawing.Color cannot be converted to System.Windows.Media.Color

Thank you in advance

----------


## jmcilhinney

You use a System.Drawing.Color in Windows Forms.  If you're using WPF then don't use a System.Drawing.Color in the first place.  Use the right type; don;t convert the wrong type to the right type.  So, where is this colour data coming from in the first place?

----------


## henrikl

Ok
I have an application in vb.net from which I like to change some colors in my WPF application located in the same Solution.
In my WPF project I have an Richtextbox in which I would like to change text color (Sytem.Windows.Media.Brush). 
I also have a DropShadowEffect where I would like to change the color (System.Windows.Media.Color)
How do I do this from vb.net ?
TIA

----------


## jmcilhinney

You are confused.  You're talking about VB.NET and WPF as though they are somehow alternatives.  They are not.  VB.NET is a programming language and WPF is an application technology.  You can create a WPF application using VB.NET or C# as the programming language and you can create applications with VB.NET as the programming language that use WPF, Windows Forms, ASP.NET Web Forms, MVC or various other options.

So, what are you actually asking for?  This WPF project of which you speak; is it an application or a library?  This VB.NET project of which you speak; is it an application or a library and, if it's an application, what technology does it use?  Are these two projects actually part of the same application?  If not, what's the relationship?

----------


## henrikl

Hi Again,
Maybe I made it difficult to understand. 
I have a solution with my vb.net project (main) and my WPF project. From the beginning I started out doing my programming in vb.net. So all my programming is done in vb.net as a programming language. The WPF is only for showing some transparent forms.
The only reason I included an WPF project was because Windows Forms are not good at true transparency. 
I hope you understand what I mean. 
Now in the WPF shown from my vb.net application by button click. I would like to change the colors as written in my previous post.

----------


## jmcilhinney

Well, if you need a System.Windows.Media.Color then create a System.Windows.Media.Color rather than a System.Drawing.Color.  Just create what you need.

If you have no choice but to convert then one has a ToArgb method and the other has a FromArgb method.

----------


## henrikl

Thank you. I will give it a try

----------


## szlamany

Why are you mixing Winforms and WPF?  They have some very fundamental differences in how the function.

Can't you just switch entirely to WPF?

Timer's are different.  Delegating to different threads is very different.

In WPF I do this (it's C#, not VB - but you should get the idea).



```
SolidColorBrush tbColor = (SolidColorBrush)new SolidColorBrush(System.Windows.Media.Color.FromRgb(208, 215, 223));
```

and also this



```
lgb.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FFFFFFFF"), 0.0));
```

----------


## henrikl

Hi szlamany,
Thank you.  I will try your solution.
I can't switch because my program made in vb.net is almost finished and also because of what I have read vb.net is a real programming language.
I didn't expect it to be that complicated to choose a color from my vb.net and set it in the wpf.

----------

