Mouse.MouseUp 附加事件


当释放任何鼠标按钮时发生。Occurs when any mouse button is released.

see AddMouseUpHandler, and RemoveMouseUpHandler
see AddMouseUpHandler, and RemoveMouseUpHandler
see AddMouseUpHandler, and RemoveMouseUpHandler


已释放的鼠标按钮通过检查事件的参数来确定。Which mouse button was released is determined by checking the arguments of the event.

这是一个附加事件。This is an attached event. WPF 将附加事件作为路由事件实现。WPF implements attached events as routed events. 附加事件本质上是一个 XAML 语言概念,用于引用可以在未定义该事件的对象上处理的事件,WPF 通过同时启用该事件来遍历路由。Attached events are fundamentally a XAML language concept for referencing events that can be handled on objects that do not define that event, which WPF expands upon by also enabling the event to traverse a route. 附加事件在代码中没有直接处理语法;若要在代码中附加路由事件的处理程序,请使用指定的 Add * 处理程序方法。Attached events do not have a direct handling syntax in code; to attach handlers for a routed event in code, you use a designated Add*Handler method. 有关详细信息,请参阅 附加事件概述For details, see Attached Events Overview.

Windows Presentation Foundation (WPF) 框架通过将其作为两个不同的公共语言运行时在上 (CLR) 事件,在此附加事件上生成 UIElementMouseLeftButtonUpMouseRightButtonUpThe Windows Presentation Foundation (WPF) framework builds on this attached event by surfacing it as two different common language runtime (CLR) events on UIElement: MouseLeftButtonUp and MouseRightButtonUp. 这些实现处理基础 MouseUp 事件并读取事件的参数,以确定是否涉及鼠标左键或右键。These implementations handle the underlying MouseUp event and read the arguments of the event to determine whether the left or right mouse button was involved. 对于三按钮,中间按钮没有框架级事件支持,您应该使用 MouseUp 事件并检查事件参数中的中间按钮条件。For three-button, there is no framework-level event support for the center button, and you should use the MouseUp event and check for the center button condition in the event arguments.

对于与鼠标相关的路由事件,请注意如何或何时将其标记为已处理。For routed events that relate to the mouse, be careful about how or when you mark them handled. 对父元素是否还应告知父元素是否还应知道是否应该知道是否有任何给定鼠标操作的难点在于,WPF 框架为何选择了将基础 Mouse 路由事件呈现为所有沿路由的 CLR 事件的模型。The difficulty in making the appropriate choices about whether parent elements should also be informed about any given mouse action is in fact why the WPF framework chose the model of having the underlying Mouse routed event be surfaced as CLR events all along the route.

隧道鼠标事件存在类似问题。Similar issues exist with tunneling mouse events. 是否应该处理事件,而不是由进一步流向源的子级处理,以及如何影响组合项可能具有预期的鼠标行为的控件中的组合?Should you handle the event and not have it be handled by children further towards the source, and how would that affect compositing in a control where the compositing pieces might have expected mouse behaviors?

路由事件信息Routed Event Information

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

对应的隧道事件为 PreviewMouseUpThe corresponding tunneling event is PreviewMouseUp.