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屬性值已從falsetrue這個項目上。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.

此事件建立的別名Mouse.MouseEnter附加事件,此類別中,以便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.

A Button (或任何ButtonBase衍生類別) 可原生處理KeyDown按鈕具有焦點,並按下的按鍵是空格鍵時的事件。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.

適用於