Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

Can anyone help.

I have a several buttons on a WPF window that I have used a horizontal Linear Gradient Bursh on when placing them on the form, using the property box.

When the button has been clicked I want the color of the gradient to change, I no longer want to to appear as Gold to White, the colour before it is clicked, I now want to to go from Green to White.

I am having real problems trying to make the brush, I am importing System.Drawing and System.Drawing.Drawing2D and the code I am trying to use is below.

VB
Dim linGrBrush As New LinearGradientBrush(New System.Drawing.Point(0, 1), New System.Drawing.Point(0, 0), System.Drawing.Color.ForestGreen, System.Drawing.Color.White)

If ntControl.IntroComp = True Then
    btnLesson1.Visibility = Windows.Visibility.Visible
    btnIntroduction.Background = linGrBrush
End If


The error I am getting says that type System.Drawing.Drawing2D.LinearGradientBrush cannot be converted to System.Windows.MediaBrush.

I am sorry if the error I am making is simple but I am pretty new to WPF all I want to do is change the background of the button.

Any Help would be much appreciated.

Kind Regards

Dave
Posted

Hello there,

Here is a link that may help you with your problem as it helped me.

http://www.ultimateprogrammingtutorials.info/2012/10/how-to-make-custom-button-in-vbnet.html

Good Luck!
 
Share this answer
 
Hi,
I do not know about this error, but i study about it in Microsoft, and i find this link. it might be useful for you:
http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.lineargradientbrush%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1[^]
Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900