silverlight 5开发【vb版】(3)-简单鼠标事件处理
程序员文章站
2022-04-29 23:18:52
...
代码如下:
Partial Public Class MainPage Inherits UserControl Private currentlocation As Point Public Sub New() InitializeComponent() End Sub Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click Label1.Content = "您好," & TextBox1.Text & "!" End Sub Private Sub LayoutRoot_MouseMove(sender As System.Object, e As System.Windows.Input.MouseEventArgs) Handles LayoutRoot.MouseMove currentlocation = e.GetPosition(LayoutRoot) Label2.Content = "现在鼠标的坐标是:(" & currentlocation.X.ToString() & "," & currentlocation.Y.ToString() & ")" End Sub End Class
移动发生在MouseMove事件中,而单击发生在Button1_Click中,click事件只适用于button控件