我试图弄清楚如何使用VB.NET动画/移动WPF中的元素。有人建议我尝试使用CompositionTarget.Rendering,但我很难开始。下面是我的代码,下面是我得到的错误消息。有人可以告诉我哪里出错了。
代码:
Imports System.ComponentModel
Class MainWindow
Dim flake0 As New flake
Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
canvas1.DataContext = flake0
AddHandler CompositionTarget.Rendering, AddressOf compo
End Sub
Private Sub compo(ByVal sender As Object, ByVal e As EventArgs)
flake0.move()
End Sub
End Class
错误:
Handles clause requires a WithEvents variable defined in the containing type or one of its base types
答案 0 :(得分:0)
我有另一种方法,意外地将“处理CompositionTarget.Rendering”标记到其末尾。