MouseWheelEventArgs 類別

定義

提供各種事件的資料,報告滑鼠裝置之滑鼠滾輪差異值的變更。Provides data for various events that report changes to the mouse wheel delta value of a mouse device.

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下列範例Delta 會在Delta滑鼠滾輪為正向下移動,並在滑鼠滾輪為負值時向下移動。TextBoxThe following example moves a TextBox up if the mouse wheel Delta is positive and moves the TextBox down if the mouse wheel Delta is negative. TextBox已附加Canvas至。The TextBox is attached to a 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會與下列事件搭配使用:MouseWheelEventArgs is used with the following events:

如果滑鼠滾輪向上或向下移動 (遠離使用者), 則屬性為正數;如果滑鼠滾輪向下移或向後移動(朝向使用者),則為負數。DeltaThe Delta property is positive if the mouse wheel is moved upward or forward (away from the user) or negative if the mouse wheel is moved downward or backward (toward the user).

即使是小型滑鼠滾輪移動, 也會引發此事件。This event is raised even for small mouse wheel movements. 在某些情況下, 您可以藉由檢查差異是否超過特定閾值, 來執行節流處理小型滑鼠滾輪差異的處理常式。For some scenarios, it is appropriate to implement handlers that throttle small mouse wheel deltas by checking whether the delta exceeds a certain threshold. 否則, 您可能會叫用處理程式, 以瞭解滑鼠滾輪差異很小的情況下, 系結至滑鼠滾輪移動的任何 UI 都不會更新。Otherwise, you might invoke your handler for cases where the mouse wheel delta was so small that any UI that is tied to the mouse wheel movement would not update. 您在處理常式中執行臨界值行為的確切方式, 以及該臨界值應完全符合實作為特定。Exactly how you implement the threshold behavior in a handler and what that threshold should be is entirely implementation-specific.

建構函式

MouseWheelEventArgs(MouseDevice, Int32, Int32)

初始化 MouseWheelEventArgs 類別的新執行個體。Initializes a new instance of the MouseWheelEventArgs class.

屬性

Delta

取得值,這個值會指出滑鼠滾輪的變更量。Gets a value that indicates the amount that the mouse wheel has changed.

Device

取得初始化這個事件的輸入裝置。Gets the input device that initiated this event.

(繼承來源 InputEventArgs)
Handled

取得或設定值,這個值表示路由事件在傳送路由時之事件處理的目前狀態。Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.

(繼承來源 RoutedEventArgs)
LeftButton

取得滑鼠左鍵的目前狀態。Gets the current state of the left mouse button.

(繼承來源 MouseEventArgs)
MiddleButton

取得滑鼠中鍵的目前狀態。Gets the current state of the middle mouse button.

(繼承來源 MouseEventArgs)
MouseDevice

取得與這個事件相關聯的滑鼠裝置。Gets the mouse device associated with this event.

(繼承來源 MouseEventArgs)
OriginalSource

在父類別進行任何可能的 Source 調整之前,取得純點擊測試所判定的原始報告來源。Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.

(繼承來源 RoutedEventArgs)
RightButton

取得滑鼠右鍵的目前狀態。Gets the current state of the right mouse button.

(繼承來源 MouseEventArgs)
RoutedEvent

取得或設定與這個 RoutedEventArgs 執行個體相關聯的 RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance.

(繼承來源 RoutedEventArgs)
Source

取得或設定引發事件之物件的參考。Gets or sets a reference to the object that raised the event.

(繼承來源 RoutedEventArgs)
StylusDevice

取得與這個事件相關聯的手寫筆裝置。Gets the stylus device associated with this event.

(繼承來源 MouseEventArgs)
Timestamp

取得這個事件發生的時間。Gets the time when this event occurred.

(繼承來源 InputEventArgs)
XButton1

取得第一個延伸的滑鼠按鍵的目前狀態。Gets the current state of the first extended mouse button.

(繼承來源 MouseEventArgs)
XButton2

取得第二個延伸的滑鼠按鍵的目前狀態。Gets the state of the second extended mouse button.

(繼承來源 MouseEventArgs)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetPosition(IInputElement)

傳回滑鼠指標相對於指定之項目的位置。Returns the position of the mouse pointer relative to the specified element.

(繼承來源 MouseEventArgs)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
InvokeEventHandler(Delegate, Object)

以型別專屬的方式叫用事件處理常式,這樣做能夠提升事件系統的效率。Invokes event handlers in a type-specific way, which can increase event system efficiency.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnSetSource(Object)

在衍生類別中覆寫時,每當執行個體的 Source 屬性值變更,便會提供通知回呼進入點。When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes.

(繼承來源 RoutedEventArgs)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於

另請參閱