Mouse.PreviewMouseDown Mouse.PreviewMouseDown Mouse.PreviewMouseDown Attached Event

定義

發生於按下任何滑鼠按鍵時。Occurs when any mouse button is depressed.

see AddPreviewMouseDownHandler, and RemovePreviewMouseDownHandler
see AddPreviewMouseDownHandler, and RemovePreviewMouseDownHandler
see AddPreviewMouseDownHandler, and RemovePreviewMouseDownHandler

備註

藉由檢查事件的引數,取決於按下哪個滑鼠鍵。Which mouse button was depressed is determined by checking the arguments of the event. 這是附加的事件 (使用通道的路由策略),目的是透過附加的事件語法來參考現有的使用者介面 (UI)user interface (UI)接受輸入的項目。This is an attached event (using tunneling routing strategy) that is intended through attached event syntax to be referenced by existing 使用者介面 (UI)user interface (UI) elements that take input.

這是附加的事件。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. 附加的事件並沒有直接處理語法在程式碼若要附加的程式碼中的路由事件處理常式,您會使用指定的新增 * 處理常式方法。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) Framework 將根據此附加事件的呈現為兩個不同通用語言執行平台 (CLR)common language runtime (CLR)上的事件UIElement:PreviewMouseLeftButtonDownPreviewMouseRightButtonDownThe 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: PreviewMouseLeftButtonDown and PreviewMouseRightButtonDown. 這些實作會處理基礎PreviewMouseDown事件和讀取事件,以判定是否牽涉到左邊或右邊的滑鼠按鈕的引數。These implementations handle the underlying PreviewMouseDown event and read the arguments of the event to determine whether the left or right mouse button was involved. 針對三個按鈕沒有架構層級事件支援中心 按鈕,而且您應該使用PreviewMouseDown事件,並查看 中心 按鈕的條件在事件引數。For three-button, there is no framework-level event support for the center button, and you should use the PreviewMouseDown 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 handling it by a child further toward the source may not be appropriate for composited controls, where the compositing pieces might have expected mouse behaviors. 做出最適當的選擇,關於是否其他項目也應被告知關於任何指定的滑鼠動作其實就是為什麼困難WPFWPFframework 選擇擁有基礎的模型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 PreviewMouseDownEvent
路由策略Routing strategy 通道Tunneling
Delegate - 委派Delegate MouseButtonEventHandler
  • 對應的事件反昇事件是MouseDownThe corresponding bubbling event is MouseDown.

適用於