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更改为trueAlthough 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.

当按钮有焦点ButtonBase且按下的键为空间条KeyDown时, (或任何派生类)对事件具有本机处理。ButtonA 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 MouseEventHandler
  • OnMouseEnter写以在派生类中实现此事件的类处理。Override OnMouseEnter to implement class handling for this event in derived classes.

适用于