Windowscommunitytoolkit: Attached property for easily changing the Cursor type

Created on 18 Jul 2017  路  9Comments  路  Source: windows-toolkit/WindowsCommunityToolkit

Currently it's not possible to easily define different cursor to be displayed over specific element, only globally using this code:

Window.Current.CoreWindow.PointerCursor = 
    new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1);

So I've created simple Mouse.Cursor helper class with simple XAML syntax: Mouse.Cursor="Hand".
cursor

Update, Pull Request with this feature is available here: https://github.com/Microsoft/UWPCommunityToolkit/pull/1593

feature helpers in progress

Most helpful comment

@martinsuchan are we planning anything on this ? I think UserVoice would be a good start but this is a helper and IMO UV in this instance could be optional

All 9 comments

I like it. Do you know if there is already a user voice entry for cursors? If not could you create one?

Love it..

Nice and simple. We need it.

Since only Mouse has a cursor, should we name it Cursor.Use="Hand" or Mouse.Cursor="Hand"? Or maybe I missed something.

I agree, Mouse.Cursor seems better. :)

This issue seems inactive. It will automatically be closed in 14 days if there is no activity.

@martinsuchan are we planning anything on this ? I think UserVoice would be a good start but this is a helper and IMO UV in this instance could be optional

Pull request https://github.com/Microsoft/UWPCommunityToolkit/pull/1593 is now available. Some notes:

  • I've changed the name of the class based on feedback from Cursor.Use to Mouse.Cursor.
  • I've actually used this feature in one of my apps in the last few months and based on the feedback/bugs I found in the process I've changed the code of the class completely. It no longer stores the elements in a collection, so no more memory leaks, and it only uses Pointer events and Unloaded event for changing the cursor property.

PR is merged

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kusanagi2k2 picture kusanagi2k2  路  4Comments

jamesmcroft picture jamesmcroft  路  3Comments

tibitoth picture tibitoth  路  3Comments

deltakosh picture deltakosh  路  3Comments

alvinashcraft picture alvinashcraft  路  3Comments