Gets or sets the cursor that displays when the mouse pointer is over this element.
Assembly: PresentationFramework (in PresentationFramework.dll)
When you set this property in XAML, the XAML processor relies on type conversion for the Cursor class to evaluate the string. The provided string should evaluate to a CursorType value. See Cursor for details.
Whether the cursor as established by this property will or will not display when the mouse pointer is over this element is also dependent on the value of the ForceCursor property. Also, event-related considerations such as an active drag, mouse capture, text editing modes within controls, and so on, will also affect the cursor with higher priority than the value you specify in this property.
To revert the behavior of setting this property to the eventual default, set it to null again.
The null default really means that determination of the practical cursor value is deferred here and should be obtained from elsewhere. If presented without programmatic values from any source, the default cursor that is visually over a Windows Presentation Foundation (WPF) application will be an arrow. However, the transient cursor changes are not set to the QueryCursor event. The event bubbles, and any element along the route has the opportunity to handle the event and to set the value of the cursor through the arguments of this event. This is the mechanism that produces the visually apparent cursor in most cases. If a QueryCursor handler returns a cursor result, then the fact that the event is handled and has a changed value in the arguments takes precedence over the value of the property at any level, unless ForceCursor is set.values of the elements when they are passed over. The property will only report non null values in cases where it was actually set, for instance through code or a style. Each movement of the mouse over a WPF application raises a
If not are not creating a custom cursor, you typically set this property to a static property value of the Cursors class. Setting in code requires one of the following:
The following example shows how to deliberately set the cursor graphic.
' When the Radiobox changes, a new cursor type is set Private Sub CursorTypeChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) Dim item As String = CType(e.Source, ComboBox).SelectedItem.Content.ToString() Select Case item Case "AppStarting" DisplayArea.Cursor = Cursors.AppStarting Case "ArrowCD" DisplayArea.Cursor = Cursors.ArrowCD Case "Arrow" DisplayArea.Cursor = Cursors.Arrow Case "Cross" DisplayArea.Cursor = Cursors.Cross Case "HandCursor" DisplayArea.Cursor = Cursors.Hand Case "Help" DisplayArea.Cursor = Cursors.Help Case "IBeam" DisplayArea.Cursor = Cursors.IBeam Case "No" DisplayArea.Cursor = Cursors.No Case "None" DisplayArea.Cursor = Cursors.None Case "Pen" DisplayArea.Cursor = Cursors.Pen Case "ScrollSE" DisplayArea.Cursor = Cursors.ScrollSE Case "ScrollWE" DisplayArea.Cursor = Cursors.ScrollWE Case "SizeAll" DisplayArea.Cursor = Cursors.SizeAll Case "SizeNESW" DisplayArea.Cursor = Cursors.SizeNESW Case "SizeNS" DisplayArea.Cursor = Cursors.SizeNS Case "SizeNWSE" DisplayArea.Cursor = Cursors.SizeNWSE Case "SizeWE" DisplayArea.Cursor = Cursors.SizeWE Case "UpArrow" DisplayArea.Cursor = Cursors.UpArrow Case "WaitCursor" DisplayArea.Cursor = Cursors.Wait Case "Custom" DisplayArea.Cursor = CustomCursor End Select ' if the cursor scope is set to the entire application ' use OverrideCursor to force the cursor for all elements If (cursorScopeElementOnly = False) Then Mouse.OverrideCursor = DisplayArea.Cursor End If End Sub
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0