添加句柄错误 [英] Add a handle errors
本文介绍了添加句柄错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Public Shared Function CreateHyperLink(ByVal sURI As String, ByVal sDescription As String, ByVal ClickMethod As EventHandler(Of System.Windows.RoutedEventArgs)) As Hyperlink Dim hyper As New Hyperlink() hyper.Inlines.Add(sDescription) hyper.NavigateUri = New System.Uri(sURI) AddHandler hyper.Click, ClickMethod Return hyper End Function
上面的代码创建了一个超链接功能.
但是..
AddHandler hyper.Click,<<< ClickMethod>>>
出现"ClickMethod"错误.
错误:
类型"System.EventHandler(Of System.Windows.RoutedEventArgs)"的值不能转换为"System.Windows.RoutedEventHandler"
解决方案
看起来像您需要传递一个RoutedEventHandler,而不是您传递的内容.
>
Public Shared Function CreateHyperLink(ByVal sURI As String, ByVal sDescription As String, ByVal ClickMethod As EventHandler(Of System.Windows.RoutedEventArgs)) As Hyperlink Dim hyper As New Hyperlink() hyper.Inlines.Add(sDescription) hyper.NavigateUri = New System.Uri(sURI) AddHandler hyper.Click, ClickMethod Return hyper End Function
The above code creates a hyperlink function.
But..
AddHandler hyper.Click, <<< ClickMethod >>>
''ClickMethod'' is the error.
Error:
Value of type ''System.EventHandler (Of System.Windows.RoutedEventArgs)'' cannot be converted to ''System.Windows.RoutedEventHandler''
How Can Fix It?
解决方案
Looks like you need to pass in a RoutedEventHandler, not what you''re passing.
这篇关于添加句柄错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文