Skip to content

Changing the mouse cursor in WinUI 3. #1816

Answered by kevinguo305
AtomicBlom asked this question in Q&A
Discussion options

You must be logged in to vote

Getting the CoreCursor from InputPointerSource is not the recommended way. We've added this new API:

Microsoft.UI.Xaml.UIElement
{
    protected CoreCursor ProtectedCursor { get; set; }
}

and we recommend instead that you subclass the UI element that you want the cursor to be changed in, and add a method that sets a ProtectedCursor property which is part of every UIElement in WinUI 3.

public void ChangeCursor(MUI::InputCursor cursor)
{
	this.ProtectedCursor = cursor;
}

Afterwards, in your main Microsoft.UI.Xaml.Controls.Page class, you can call the subclassed UI Element.ChangeCursor(InputSystemCursor.Create(*insert InputSystemCursorShape enum value*));

Replies: 19 comments 18 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@nghia-vt
Comment options

@asierpn
Comment options

@nghia-vt
Comment options

@br441
Comment options

@codendone
Comment options

Answer selected by Kevin-Taha
Comment options

You must be logged in to vote
2 replies
@legistek
Comment options

@amercer-fdi
Comment options

Comment options

You must be logged in to vote
1 reply
@legistek
Comment options

Comment options

You must be logged in to vote
2 replies
@legistek
Comment options

@amercer-fdi
Comment options

Comment options

You must be logged in to vote
1 reply
@legistek
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@zkvii
Comment options

Comment options

You must be logged in to vote
2 replies
@asierpn
Comment options

@DarranRowe
Comment options

Comment options

You must be logged in to vote
1 reply
@vmiguelangmsft
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment