Mouse.OverrideCursor Property

Definition

Gets or sets the cursor for the entire application.

C#
public static System.Windows.Input.Cursor OverrideCursor { get; set; }

Property Value

The override cursor or null if the OverrideCursor is not set.

Examples

The following example shows an event handler for a RadioButton that is used to toggle the scope of a cursor change between a single element and the entire application. If the control that raised the event is the rbScopeElement RadioButton, a flag that denotes the scope of the cursor change is set and OverrideCursor is set to null. If the control that raised the event is the rbScopeApplication RadioButton, a flag that denotes the scope of the cursor change is set and OverrideCursor is set to the Cursor property of the Border control named DisplayArea.

C#
// Determines the scope the new cursor will have.
//
// If the RadioButton rbScopeElement is selected, then the cursor
// will only change on the display element.
// 
// If the Radiobutton rbScopeApplication is selected, then the cursor
// will be changed for the entire application
//
private void CursorScopeSelected(object sender, RoutedEventArgs e)
{
    RadioButton source = e.Source as RadioButton;

    if (source != null)
    {
        if (source.Name == "rbScopeElement")
        {
            // Setting the element only scope flag to true
            cursorScopeElementOnly = true;

            // Clearing out the OverrideCursor.  
            Mouse.OverrideCursor = null;
        }
        if (source.Name == "rbScopeApplication")
        {
           // Setting the element only scope flag to false
           cursorScopeElementOnly = false;

           // Forcing the cursor for all elements. 
           Mouse.OverrideCursor = DisplayArea.Cursor;
        }
    }
}

Remarks

The Cursor that OverrideCursor is set to will be applied to the whole application.

To clear the override Cursor, set OverrideCursor to null.

Setting OverrideCursor to None will force the mouse cursor not to be displayed, but mouse events are still processed.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9