Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Mouse.OverrideCursor Property

Gets or sets the cursor for the entire application.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public static Cursor OverrideCursor { get; set; }
/** @property */
public static Cursor get_OverrideCursor ()

/** @property */
public static void set_OverrideCursor (Cursor value)

public static function get OverrideCursor () : Cursor

public static function set OverrideCursor (value : Cursor)

You cannot use this property in XAML.

Property Value

The override cursor or a null reference (Nothing in Visual Basic) if the OverrideCursor is not set.

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

To clear the override Cursor, set OverrideCursor to a null reference (Nothing in Visual Basic).

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

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 rbScopeElementRadioButton, a flag that denotes the scope of the cursor change is set and OverrideCursor is set to a null reference (Nothing in Visual Basic). If the control that raised the event is the rbScopeApplicationRadioButton, 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. For the full source code for this example, see the sample Changing the Cursor Type Sample.

// 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
//
public 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;
        }
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show:
© 2018 Microsoft