UIElement.QueryCursor UIElement.QueryCursor UIElement.QueryCursor UIElement.QueryCursor Event

定义

当请求显示光标时发生。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.

public:
 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附加事件的别名, 因此当继承QueryCursor为基元素时UIElement , 它是类成员列表的一部分。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. 该对象由 WPF 中的Cursor类表示。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. 相反, 每个元素应通过CursorForceCursor定义其自己的游标行为。Instead, 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.

适用于

另请参阅