silverlight 5开发【vb版】(6)-鼠标滚轮事件
程序员文章站
2022-03-02 11:47:06
...
If e.Delta > 0 Then Label3.Content = Label3.Content + 1 Else Label3.Content = Label3.Content - 1 End If
e.Delta > 0表示向上滚,否则为向下滚
接上节,完整代码如下:
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 Private Sub LayoutRoot_MouseLeftButtonDown(sender As System.Object, e As System.Windows.Input.MouseButtonEventArgs) Handles LayoutRoot.MouseLeftButtonDown MessageBox.Show("您按了左键") End Sub Private Sub LayoutRoot_MouseRightButtonDown(sender As System.Object, e As System.Windows.Input.MouseButtonEventArgs) Handles LayoutRoot.MouseRightButtonDown MessageBox.Show("您按了右键") End Sub Private Sub Label3_MouseWheel(sender As System.Object, e As System.Windows.Input.MouseWheelEventArgs) Handles Label3.MouseWheel If e.Delta > 0 Then Label3.Content = Label3.Content + 1 Else Label3.Content = Label3.Content - 1 End If End Sub End Class
截图如下:
当鼠标滚轮在label控件中活动时,事件发生,这里的例子是使label控件中的值变大或变小
整个工程代码见附件
推荐阅读
-
silverlight 5开发【vb版】(6)-鼠标滚轮事件
-
silverlight 5开发【vb版】(11)- 样式与模板
-
silverlight 5开发【vb版】(12)-数据和RIA基础(2)
-
silverlight 5开发【vb版】(7)-silverlight 5开发工具包ISO
-
silverlight 5开发【vb版】(12)-数据和RIA基础(1)
-
silverlight 5开发【vb版】(5)-鼠标左右键事件
-
silverlight 5开发【vb版】(3)-简单鼠标事件处理
-
silverlight 5开发【vb版】(4)-容器
-
silverlight 5开发【vb版】(10)- 布局控件
-
silverlight 5开发【vb版】(3)-简单鼠标事件处理