UIElement.GotMouseCapture 事件

定义

在此元素捕获鼠标时发生。Occurs when this element captures the mouse.

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

实现

注解

当某个元素捕获鼠标时,它将接收鼠标输入,即使鼠标指针在其边界之外也是如此。When an element captures the mouse, it receives mouse input even if the mouse pointer is outside its bounds. 通常仅在拖放操作期间捕获鼠标,并在拖放操作的删除操作发生之前捕获该鼠标。The mouse is typically captured only during drag-and-drop operations and remains captured until the drop action of the drag-and-drop operation occurs.

由于此事件使用冒泡路由,因此具有捕获的元素可以是子元素,而不是实际附加事件处理程序的元素。Because this event uses bubbling routing, the element that has capture might be a child element instead of the element where the event handler is actually attached. 检查事件数据中的 Source,以确定具有鼠标捕获的实际元素。Check the Source in the event data to determine the actual element that has mouse capture.

此事件将为此类创建 Mouse.GotMouseCapture 附加事件的别名,以便在将 UIElement 作为基元素继承时,GotMouseCapture 是类成员列表的一部分。This event creates an alias for the Mouse.GotMouseCapture attached event for this class so that GotMouseCapture is part of the class members list when UIElement is inherited as a base element. 附加到 GotMouseCapture 事件的事件处理程序附加到基础 Mouse.GotMouseCapture 附加事件,并接收相同的事件数据实例。Event handlers that are attached to the GotMouseCapture event are attached to the underlying Mouse.GotMouseCapture attached event and receive the same event data instance.

路由事件信息Routed Event Information

标识符字段Identifier field GotMouseCaptureEvent
路由策略Routing strategy 冒泡Bubbling
委托Delegate MouseEventHandler
  • 未定义相应的隧道事件。There is no defined corresponding tunneling event.

  • 重写 OnGotMouseCapture 在派生类中实现此事件的类处理。Override OnGotMouseCapture to implement class handling for this event in derived classes.

适用于

另请参阅