通过


MouseWheelEventArgs 类

定义

为报告鼠标设备鼠标滚轮增量值更改的各种事件提供数据。

public ref class MouseWheelEventArgs : System::Windows::Input::MouseEventArgs
public class MouseWheelEventArgs : System.Windows.Input.MouseEventArgs
type MouseWheelEventArgs = class
    inherit MouseEventArgs
Public Class MouseWheelEventArgs
Inherits MouseEventArgs
继承

示例

以下示例在鼠标滚轮为正时向上移动TextBox,并在鼠标滚DeltaDelta为负时向下移动TextBox。 附加到 TextBox .Canvas

// Moves the TextBox named box when the mouse wheel is rotated.
// The TextBox is on a Canvas named MainCanvas.
private void MouseWheelHandler(object sender, MouseWheelEventArgs e)
{
    // If the mouse wheel delta is positive, move the box up.
    if (e.Delta > 0)
    {
        if (Canvas.GetTop(box) >= 1)
        {
            Canvas.SetTop(box, Canvas.GetTop(box) - 1);
        }
    }

    // If the mouse wheel delta is negative, move the box down.
    if (e.Delta < 0)
    {
        if ((Canvas.GetTop(box) + box.Height) <= (MainCanvas.Height))
        {
            Canvas.SetTop(box, Canvas.GetTop(box) + 1);
        }
    }
}
' Moves the TextBox named box when the mouse wheel is rotated.
' The TextBox is on a Canvas named MainCanvas.
Private Sub MouseWheelHandler(ByVal sender As Object, ByVal e As MouseWheelEventArgs)
    ' If the mouse wheel delta is positive, move the box up.
    If e.Delta > 0 Then
        If Canvas.GetTop(box) >= 1 Then
            Canvas.SetTop(box, Canvas.GetTop(box) - 1)
        End If
    End If

    ' If the mouse wheel delta is negative, move the box down.
    If e.Delta < 0 Then
        If (Canvas.GetTop(box) + box.Height) <= MainCanvas.Height Then
            Canvas.SetTop(box, Canvas.GetTop(box) + 1)
        End If
    End If

End Sub

注解

MouseWheelEventArgs 用于以下事件:

如果鼠标滚轮向上或向前移动(远离用户),或者如果鼠标滚轮向下或向后移动(向用户移动),则 Delta 此属性为正值。

即使对于小型鼠标滚轮移动,也会引发此事件。 在某些情况下,通过检查增量是否超过特定阈值,实现限制小型鼠标滚轮增量的处理程序是适当的。 否则,对于鼠标滚轮增量如此小的情况,你可能会调用处理程序,以至于任何绑定到鼠标滚轮移动的 UI 都不会更新。 确切地说,如何在处理程序中实现阈值行为,以及该阈值应完全特定于实现的行为。

构造函数

名称 说明
MouseWheelEventArgs(MouseDevice, Int32, Int32)

初始化 MouseWheelEventArgs 类的新实例。

属性

名称 说明
Delta

获取一个值,该值指示鼠标滚轮已更改的量。

Device

获取启动此事件的输入设备。

(继承自 InputEventArgs)
Handled

获取或设置一个值,该值指示路由事件在传输路由时的事件处理的当前状态。

(继承自 RoutedEventArgs)
LeftButton

获取鼠标左键的当前状态。

(继承自 MouseEventArgs)
MiddleButton

获取鼠标中间按钮的当前状态。

(继承自 MouseEventArgs)
MouseDevice

获取与此事件关联的鼠标设备。

(继承自 MouseEventArgs)
OriginalSource

获取由纯命中测试确定的原始报告源,然后再由父类进行任何可能的 Source 调整。

(继承自 RoutedEventArgs)
RightButton

获取鼠标右键的当前状态。

(继承自 MouseEventArgs)
RoutedEvent

获取或设置 RoutedEvent 与此 RoutedEventArgs 实例关联的项。

(继承自 RoutedEventArgs)
Source

获取或设置对引发事件的对象的引用。

(继承自 RoutedEventArgs)
StylusDevice

获取与此事件关联的触笔设备。

(继承自 MouseEventArgs)
Timestamp

获取发生此事件的时间。

(继承自 InputEventArgs)
XButton1

获取第一个扩展鼠标按钮的当前状态。

(继承自 MouseEventArgs)
XButton2

获取第二个扩展鼠标按钮的状态。

(继承自 MouseEventArgs)

方法

名称 说明
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetPosition(IInputElement)

返回鼠标指针相对于指定元素的位置。

(继承自 MouseEventArgs)
GetType()

获取当前实例的 Type

(继承自 Object)
InvokeEventHandler(Delegate, Object)

以特定于类型的方式调用事件处理程序,从而提高事件系统效率。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
OnSetSource(Object)

在派生类中重写时,每当实例属性的值 Source 发生更改时,都提供通知回调入口点。

(继承自 RoutedEventArgs)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅