无法执行 RoutedEventHandler
我有循环来创建一列按钮,现在我希望将事件处理程序实现到所有按钮中,但不起作用。
创建一列按钮的迭代,
For e As Integer = 0 To 19
btnFriday(e) = New Button()
btnFriday(e).Height = 23
btnFriday(e).Width = 150
btnFriday(e).SetValue(Grid.ColumnProperty, 9)
btnFriday(e).SetValue(Grid.RowProperty, e + 1)
btnFriday(e).Click += New RoutedEventHandler(AddressOf btnBookSlot_Click)
LayoutRoot.Children.Add(btnFriday(e))
Next
我希望像单击 1 个 btnFriday 时那样,然后执行以下事件,该事件打开一个名为 Bookslot 的子窗口,
Private Sub btnBookSlot_Click(sender As Object, e As RoutedEventArgs)
Dim btn As Button = DirectCast(sender, Button)
Dim bookSlot As New BookSlot()
bookSlot.show()
End Sub
并且我收到如下错误
公共事件点击(发送者作为对象,e作为 System.Windows.RoatedEventArgs)' 是一个事件,无法调用 直接地。使用“RaiseEvent”语句引发事件
大多数解决方案都是使用 C# 和 silverlight 构建的,而且它们似乎运行良好。虽然我在使用 VB.NET 和 silverlight 时遇到问题,有什么想法吗?
I have loop to create a column of button and now i wish to implemented the eventhandler into all the buttons but is not working.
The iteration to create a column of button
For e As Integer = 0 To 19
btnFriday(e) = New Button()
btnFriday(e).Height = 23
btnFriday(e).Width = 150
btnFriday(e).SetValue(Grid.ColumnProperty, 9)
btnFriday(e).SetValue(Grid.RowProperty, e + 1)
btnFriday(e).Click += New RoutedEventHandler(AddressOf btnBookSlot_Click)
LayoutRoot.Children.Add(btnFriday(e))
Next
I wish to do like when 1 of the btnFriday is clicked then perform the below event which is open a childwindow called as Bookslot
Private Sub btnBookSlot_Click(sender As Object, e As RoutedEventArgs)
Dim btn As Button = DirectCast(sender, Button)
Dim bookSlot As New BookSlot()
bookSlot.show()
End Sub
And i receive error like
Public Event Click(sender As Object, e As
System.Windows.RoutedEventArgs)' is an event, and cannot be called
directly. Use a 'RaiseEvent' statement to raise an event
Most of the solutions were built using C# with silverlight and they seem to be working great. While i having problem by using VB.NET with silverlight Any idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信你需要改变的是
:
I believe all you need to change is:
To: