Skip to main content
.NET Framework Class Library
UIElementQueryCursor 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.

Namespace:   System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax
Public Event QueryCursor As [%$TOPIC/ms596783_en-us_VS_110_1_0_0_0_0%]
public event [%$TOPIC/ms596783_en-us_VS_110_1_0_1_0_0%] QueryCursor
public:
 event [%$TOPIC/ms596783_en-us_VS_110_1_0_2_0_0%]^ QueryCursor {
	void add ([%$TOPIC/ms596783_en-us_VS_110_1_0_2_0_1%]^ value);
	void remove ([%$TOPIC/ms596783_en-us_VS_110_1_0_2_0_2%]^ value);
}
member QueryCursor : IEvent<[%$TOPIC/ms596783_en-us_VS_110_1_0_3_0_0%],
    [%$TOPIC/ms596783_en-us_VS_110_1_0_3_0_1%]>
JScript does not support events.
<object QueryCursor="[%$TOPIC/ms596783_en-us_VS_110_1_0_5_0_0%]" .../>
Routed Event Information

Identifier field

QueryCursorEvent

Routing strategy

Bubbling

Delegate

QueryCursorEventHandler

  • There is no defined corresponding tunneling event.

  • Override OnQueryCursor to implement class handling for this event in derived classes.

Remarks

This event creates an alias for the MouseQueryCursor attached event for this class, so that QueryCursor is part of the class members list when UIElement is inherited as a base element. Event handlers that are attached to the QueryCursor event are attached to the underlying MouseQueryCursor 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). 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. That object is represented by the Cursor class in WPF. The WPF input system enables you to change this cursor when it represents the onscreen position of the mouse pointer. You can use predefined values from the Cursors enumeration, or you can declare a custom cursor as an image file.

Listening for the QueryCursor event is not an efficient technique for cursor management. Instead, each element should define its own cursor behavior with Cursor and ForceCursor. 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. For more information on implementing cursor behavior in response to QueryCursor, see QueryCursorEventHandler.

Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1