UIElement.QueryCursor 事件


要求顯示游標時發生。Occurs when the cursor is requested to display. 每當滑鼠指標移動至新位置時,都會引發此事件,這意謂游標物件可能會根據其新位置而變更。This event is raised on an element each time that the mouse pointer moves to a new location, which means the cursor object might need to be changed based on its new position.

 event System::Windows::Input::QueryCursorEventHandler ^ QueryCursor;
public event System.Windows.Input.QueryCursorEventHandler QueryCursor;
member this.QueryCursor : System.Windows.Input.QueryCursorEventHandler 
Public Custom Event QueryCursor As QueryCursorEventHandler 




此事件 Mouse.QueryCursor 會為這個類別建立附加事件的別名,因此 QueryCursorUIElement 繼承為基底專案時,它就是類別成員清單的一部分。This event creates an alias for the Mouse.QueryCursor attached event for this class, so that QueryCursor is part of the class members list when UIElement is inherited as a base element. 附加至事件的事件處理常式 QueryCursor 會附加至基礎 Mouse.QueryCursor 附加事件,並接收相同的事件資料實例。Event handlers that are attached to the QueryCursor event are attached to the underlying Mouse.QueryCursor attached event and receive the same event data instance.

此事件名稱所參考的資料指標不一定是文字游標 (有時也稱為插入點) 。The cursor being referred to by this event name is not necessarily the text cursor (sometimes known as the insertion point). 相反地,此內容中的資料指標是一個物件,該物件會宣告與 Windows 程式設計中數個可能輸入相關裝置或概念相關的螢幕圖形顯示。Instead, the cursor in this context is the object that declares the onscreen graphical display related to several possible input-related devices or concepts in Windows programming. 該物件是由 Cursor WPF 中的類別表示。That object is represented by the Cursor class in WPF. WPF 輸入系統可讓您在表示滑鼠指標的螢幕位置時,變更這個資料指標。The WPF input system enables you to change this cursor when it represents the onscreen position of the mouse pointer. 您可以從列舉中使用預先定義的值 Cursors ,也可以將自訂資料指標宣告為影像檔案。You can use predefined values from the Cursors enumeration, or you can declare a custom cursor as an image file.

接聽 QueryCursor 事件並不是資料指標管理的有效技術。Listening for the QueryCursor event is not an efficient technique for cursor management. 相反地,每個元素都應該使用和定義其本身的資料指標行為 Cursor ForceCursorInstead, each element should define its own cursor behavior with Cursor and ForceCursor. 您應該只依賴 QueryCursor 您不是使用 WPF 架構層級的基底專案,或在特別的情況下,在每個元素上定義資料指標行為,並不符合您的需求。You should only rely on QueryCursor if you are not using the WPF framework-level base elements, or in extraordinary circumstances where defining cursor behavior on a per-element basis does not meet your needs. 如需有關在回應中執行資料指標行為的詳細資訊 QueryCursor ,請參閱 QueryCursorEventHandlerFor more information on implementing cursor behavior in response to QueryCursor, see QueryCursorEventHandler.

路由事件資訊Routed Event Information

識別碼欄位Identifier field QueryCursorEvent
路由策略Routing strategy 鼓 泡Bubbling
代理人Delegate QueryCursorEventHandler
  • 沒有已定義的對應通道事件。There is no defined corresponding tunneling event.

  • OnQueryCursor在衍生類別中覆寫以執行這個事件的類別處理。Override OnQueryCursor to implement class handling for this event in derived classes.