-
Oct 27th, 2013, 02:07 AM
#1
Thread Starter
Addicted Member
VB.NET color to WPF color
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
-
Oct 27th, 2013, 02:15 AM
#2
Re: VB.NET color to WPF color
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?
-
Oct 27th, 2013, 02:40 AM
#3
Thread Starter
Addicted Member
Re: VB.NET color to WPF color
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
-
Oct 27th, 2013, 03:09 AM
#4
Re: VB.NET color to WPF color
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?
-
Oct 27th, 2013, 03:41 AM
#5
Thread Starter
Addicted Member
Re: VB.NET color to WPF color
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.
-
Oct 27th, 2013, 03:51 AM
#6
Re: VB.NET color to WPF color
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.
-
Oct 27th, 2013, 06:11 AM
#7
Thread Starter
Addicted Member
Re: VB.NET color to WPF color
Thank you. I will give it a try
-
Oct 27th, 2013, 06:14 AM
#8
Re: VB.NET color to WPF color
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).
Code:
SolidColorBrush tbColor = (SolidColorBrush)new SolidColorBrush(System.Windows.Media.Color.FromRgb(208, 215, 223));
and also this
Code:
lgb.GradientStops.Add(new GradientStop((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#FFFFFFFF"), 0.0));
-
Oct 27th, 2013, 06:36 AM
#9
Thread Starter
Addicted Member
Re: VB.NET color to WPF color
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|