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。 附加 TextBoxCanvas

// 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

取得或設定與這個 RoutedEventArgs 執行個體相關聯的 RoutedEvent

(繼承來源 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)

適用於

另請參閱