CoreCursor CoreCursor CoreCursor CoreCursor Class

Definition

Defines a cursor (visual pointer) object.

public : sealed class CoreCursor : ICoreCursor
public sealed class CoreCursor : ICoreCursor
Public NotInheritable Class CoreCursor Implements ICoreCursor
var coreCursor = new coreCursor(type, id);
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

This example shows how to set a "hand" cursor when the pointer is over a button.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Button Content="Button 1"
            PointerEntered="Button_PointerEntered"
            PointerExited="Button_PointerExited"/>
</Grid>
public sealed partial class MainPage : Page
{
    CoreCursor buttonCursor = null;
    CoreCursor cursorBeforePointerEntered = null;

    public MainPage()
    {
        this.InitializeComponent();
        buttonCursor = new CoreCursor(CoreCursorType.Hand, 0);
    }

    private void Button_PointerEntered(object sender, PointerRoutedEventArgs e)
    {
        // Cache the cursor set before pointer enter on button.
        cursorBeforePointerEntered = Window.Current.CoreWindow.PointerCursor;
        // Set button cursor.
        Window.Current.CoreWindow.PointerCursor = buttonCursor;
    }

    private void Button_PointerExited(object sender, PointerRoutedEventArgs e)
    {
        // Change the cursor back.
        Window.Current.CoreWindow.PointerCursor = cursorBeforePointerEntered;
    }
}

Remarks

To create a CoreCursor instance using a pre-defined Windows cursor, use any of the cursor types available in the CoreCursorType enumeration other than Custom. In this case, the Id property is ignored.

To use a custom cursor, use the CoreCursorType.Custom enumeration option, and specify the Id of the custom cursor. You can add a .res resource file that contains the custom cursor to your project and include it in your assembly with the /win32res compiler option. The Id is the Cursor Resource ID specified in the .res file.

Constructors

CoreCursor(CoreCursorType, UInt32) CoreCursor(CoreCursorType, UInt32) CoreCursor(CoreCursorType, UInt32) CoreCursor(CoreCursorType, UInt32)

Creates a new CoreCursor instance of the provided cursor type.

public : CoreCursor(CoreCursorType type, unsigned int id)
public CoreCursor(CoreCursorType type, UInt32 id)
Public Sub New(type As CoreCursorType, id As UInt32)
var coreCursor = new coreCursor(type, id);
Parameters
type
CoreCursorType CoreCursorType CoreCursorType CoreCursorType

The type of the new cursor.

id
unsigned int UInt32 UInt32 UInt32

The unique resource ID of the new cursor.

Properties

Id Id Id Id

Gets the resource ID of the cursor.

public : unsigned int Id { get; }
public uint Id { get; }
Public ReadOnly Property Id As uint
var uint = coreCursor.id;
Value
unsigned int uint uint uint

The ID of the cursor.

Type Type Type Type

Gets the type of the cursor.

public : CoreCursorType Type { get; }
public CoreCursorType Type { get; }
Public ReadOnly Property Type As CoreCursorType
var coreCursorType = coreCursor.type;