ContentElement.MouseDown 事件


在指针位于此元素上并且按下任意鼠标按钮时发生。Occurs when any mouse button is pressed while the pointer is over this element.

 event System::Windows::Input::MouseButtonEventHandler ^ MouseDown;
public event System.Windows.Input.MouseButtonEventHandler MouseDown;
member this.MouseDown : System.Windows.Input.MouseButtonEventHandler 
Public Custom Event MouseDown As MouseButtonEventHandler 




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

MouseDown事件通常与或一起引发 MouseLeftButtonDown MouseRightButtonDown ,这对应于按下这两个标准鼠标按钮之一。The MouseDown event is often raised together with either MouseLeftButtonDown or MouseRightButtonDown, which correspond to a press of one of the two standard mouse buttons. MouseLeftButtonDownMouseRightButtonDown 也是路由事件,但它们是直接路由事件,当 Mouse.MouseDown 事件沿事件路由到达此元素时,将引发相应的按钮特定的事件。MouseLeftButtonDown and MouseRightButtonDown are also routed events, but they are direct routed events, and the appropriate button-specific event is raised when the Mouse.MouseDown event reaches this element along the event route. 请参阅或的 "备注" MouseLeftButtonDown MouseRightButtonDownSee Remarks for MouseLeftButtonDown or MouseRightButtonDown.


有些 ContentElement 具有类似于控件的行为的派生类(例如, Hyperlink )可能具有鼠标按钮事件的固有类处理。A few ContentElement derived classes that have control-like behavior, for example, Hyperlink, might have inherent class handling for mouse button events. 鼠标左键按下事件是在控件中具有类处理的最可能的事件。The left mouse button down event is the most likely event to have class handling in a control. 类处理通常将基础 Mouse 类事件标记为已处理。The class handling often marks the underlying Mouse class event as handled. 将该事件标记为已处理后,通常不会引发附加到该元素的其他实例处理程序。Once the event is marked handled, other instance handlers that are attached to that element are not ordinarily raised. 通常也不会引发在冒泡方向上沿 UI 树中的根向下附加到元素的任何其他类或实例处理程序。Any other class or instance handlers that are attached to elements in the bubbling direction towards the root in the UI tree are also not ordinarily raised.

您可以 MouseDown 通过使用以下任一解决方案解决在具有类处理的派生类上的 "上一重要" 和 "接收鼠标左键按下事件" 事件中所述的问题:You can resolve the issue that is outlined in the preceding Important and still receive MouseDown events for left mouse button down events on a derived class that has class handling by using either of these solutions:

  • 为事件附加处理程序 PreviewMouseDown ,这些处理程序未标记为由控件处理。Attach handlers for the PreviewMouseDown event, which is not marked as handled by the controls. 请注意,因为这是预览事件,所以路由从根节点开始,向下隧道到控件。Notice that because this is a preview event, the route starts at the root and tunnels down to the control.

  • 通过调用 AddHandler 并选择允许处理程序侦听事件的签名选项(即使它们已在路由事件数据中标记为已处理),在控件过程上注册处理程序。Register a handler on the control procedurally by calling AddHandler and choosing the signature option that enables handlers to listen for events even if they are already marked as handled in the routed event data.

路由事件信息Routed Event Information

标识符字段Identifier field MouseDownEvent
路由策略Routing strategy 冒泡Bubbling
委托Delegate MouseButtonEventHandler