VB.NET中的线性渐变画笔 [英] Linear Gradient Brush in VB.NET
问题描述
嗨
任何人都可以提供帮助。
我在WPF窗口上有几个按钮当我们使用属性框将它们放置在表单上时,我使用了水平线性渐变Bursh。
单击按钮时我想要渐变的颜色为了改变,我不再希望看到黄金到白色,点击之前的颜色,我现在想要从绿色变为白色。
我我正在尝试制作画笔时遇到实际问题,我正在导入System.Drawing和System.Drawing.Drawing2D,我正在尝试使用的代码如下。
< pre lang =vb> Dim linGrBrush As New LinearGradientBrush( New System.Drawing.Point( 0 , 1 ),新 System.Drawing.Point( 0 , 0 ),System.Drawing.Color.ForestGreen,System.Drawing.Color.White)
如果 ntControl.IntroComp = True 那么
btnLesson1.Visibility = Windows.Visibility.Visible
btnIntroduction.Background = linGrBrush
End 如果
我得到的错误说类型System.Drawing.Drawing2D.LinearGradientBrush不能转换为System.Windows.MediaBrush。
如果我所犯的错误很简单,我很抱歉,我对WPF很新,我想做的就是改变按钮的背景。
任何帮助将不胜感激。
亲切的问候
Dave
你好,
这里是一个链接这可以帮助你解决问题,因为它帮助了我。
http://www.ultimateprogrammingtutorials.info/2012/10/how-to-make-custom- button-in-vbnet.html
好运!
我不知道知道这个错误,但我在微软研究它,我找到了这个链接。它可能对你有用:
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 [ ^ ]
问候,
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.
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
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!
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,
这篇关于VB.NET中的线性渐变画笔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!