UIElement.MouseEnter UIElement.MouseEnter UIElement.MouseEnter UIElement.MouseEnter Event

定義

滑鼠指標進入此元素的邊界時發生。Occurs when the mouse pointer enters the bounds of this element.

public:
 virtual event System::Windows::Input::MouseEventHandler ^ MouseEnter;
public event System.Windows.Input.MouseEventHandler MouseEnter;
member this.MouseEnter : System.Windows.Input.MouseEventHandler 
Public Custom Event MouseEnter As MouseEventHandler 

實作

備註

MouseEnter是使用直接事件處理路由策略的路由事件MouseEnter is a routed event that uses the direct event handling routing strategy. 直接路由事件不會沿著路由引發;相反地, 它們會在引發它們的相同專案中進行處理。Direct routed events are not raised along a route; instead, they are handled in the same element where they are raised. 不過, 它們會啟用路由事件行為的其他層面, 例如樣式中的事件觸發程式。However, they do enable other aspects of routed event behavior, such as event triggers in styles.

雖然MouseEnter會在滑鼠指標進入專案的範圍時追蹤, 但這個事件會更常報告屬性IsMouseOver值已從false變更為true這個專案上的。Although MouseEnter tracks when the mouse pointer enters the bounds of an element, this event more literally reports that the IsMouseOver property value has changed from false to true on this element.

這個事件MouseEnter會為這個類別建立Mouse.MouseEnter附加事件的別名, 因此當繼承為基底專案時UIElement , 就是類別成員清單的一部分。This event creates an alias for the Mouse.MouseEnter attached event for this class, so that MouseEnter is part of the class members list when UIElement is inherited as a base element. 附加至MouseEnter事件的事件處理常式會附加至基礎Mouse.MouseEnter附加事件, 並接收相同的事件資料實例。Event handlers that are attached to the MouseEnter event are attached to the underlying Mouse.MouseEnter attached event and receive the same event data instance.

當按鈕具有焦點ButtonBase時, KeyDown (或任何衍生類別)有事件的原生處理,而按下的Button按鍵是空格鍵。A Button (or any ButtonBase derived class) has native handling for a KeyDown event when the button has focus, and the pressed key is the space bar. 原生處理會引發Click事件, 並以按鈕做為來源, 也會捕捉滑鼠, 即使滑鼠指標似乎不會移動也一樣。The native handling raises the Click event with the button as the source, and also captures the mouse, even though the mouse pointer does not appear to move. 由於滑鼠捕捉的結果, MouseEnter事件也會引發, 並以按鈕做為來源。As a result of the mouse capture, a MouseEnter event is also raised with the button as the source. 一般來說, 如果元素MouseEnter會捕捉滑鼠, 則會引發, GotMouseCapture以及可能的其他控制項特定事件。In general, if an element captures the mouse, then MouseEnter is raised, as well as GotMouseCapture and possibly other control-specific events.

路由事件資訊Routed Event Information

識別碼欄位Identifier field MouseEnterEvent
路由策略Routing strategy 直接Direct
Delegate - 委派Delegate MouseEventHandler
  • OnMouseEnter寫以在衍生類別中為這個事件執行類別處理。Override OnMouseEnter to implement class handling for this event in derived classes.

適用於