Mouse.PreviewMouseUp 附加事件


發生於放開任何滑鼠按鍵時。Occurs when any mouse button is released.

see AddPreviewMouseUpHandler, and RemovePreviewMouseUpHandler
see AddPreviewMouseUpHandler, and RemovePreviewMouseUpHandler
see AddPreviewMouseUpHandler, and RemovePreviewMouseUpHandler


已釋放的滑鼠按鍵是藉由檢查事件的引數所決定。Which mouse button was released is determined by checking the arguments of the event.

這是附加事件。This is an attached event. WPFWPF 將附加事件實作為路由事件。implements attached events as routed events. 附加事件基本上是參考事件的一種 XAMLXAML 語言概念,可以在未定義該事件的物件上處理,這 WPFWPF 也會讓事件通過路由來進行擴充。Attached events are fundamentally a XAMLXAML language concept for referencing events that can be handled on objects that do not define that event, which WPFWPF 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)Windows Presentation Foundation (WPF)架構會在這個附加事件上建立,其方式是在上將它呈現為兩個不同 通用語言執行平台 (CLR)common language runtime (CLR) 的事件 UIElementPreviewMouseLeftButtonUpPreviewMouseRightButtonUpThe Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) framework builds on this attached event by surfacing it as two different 通用語言執行平台 (CLR)common language runtime (CLR) events on UIElement: PreviewMouseLeftButtonUp and PreviewMouseRightButtonUp. 這些執行會處理基礎 PreviewMouseUp 事件並讀取事件的引數,以判斷是否牽涉到左或右滑鼠按鍵。These implementations handle the underlying PreviewMouseUp event and read the arguments of the event to determine whether the left or right mouse button was involved. 針對三個按鈕,中間按鈕沒有架構層級的事件支援,而且您應該使用 PreviewMouseUp 事件並檢查事件引數中的置中按鈕條件。For three-button, there is no framework-level event support for the center button, and you should use the PreviewMouseUp 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. 將事件處理到根附近,而不是由子系進一步向來源處理,可能不適用於複合控制項,其中的組合部分可能會有預期的滑鼠行為。Handling the event near the root and not handling by a child further toward the source may not be appropriate for composited controls, where the compositing pieces might have expected mouse behaviors. 做出適當選擇是否也應該知道是否有任何指定的滑鼠動作,是因為 WPFWPF 架構選擇了讓基礎 Mouse 路由事件呈現為 CLRCLR 路由中事件的模型,這是很困難的。The difficulty in making the appropriate choices about whether other elements should also be informed about any given mouse action is in fact why the WPFWPF framework chose the model of having the underlying Mouse routed event be surfaced as CLRCLR events along the route.

路由事件資訊Routed Event Information

識別碼欄位Identifier field PreviewMouseUpEvent
路由策略Routing strategy 隧道Tunneling
代理人Delegate MouseButtonEventHandler
  • 對應的反升事件為 MouseUpThe corresponding bubbling event is MouseUp.