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.

UIElement 通用語言執行平台 (CLR)common language runtime (CLR) PreviewMouseRightButtonUp PreviewMouseLeftButtonUp架構會在這個附加事件上建立, 其方式是在上將它呈現為兩個不同的事件: 和。 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)The 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 - 委派Delegate MouseButtonEventHandler
  • 對應的反升事件MouseUp為。The corresponding bubbling event is MouseUp.

適用於