microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.8k stars 321 forks source link

Custom cursor doesn't respond to DPI changes (and is inconvenient to add in C# app) #238

Open benstevens48 opened 3 years ago

benstevens48 commented 3 years ago

I've just been experimenting with adding a custom cursor in my UWP app like this.

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

It works OK, except that if I change the system DPI when the app is open then the cursor does not update to use the appropriately sized bitmap in the cur file, unlike the system cursors. It just gets scaled and looks pixelated. It does work if I restart the app after the DPI change. (Note that my cur file contains 128*128, 96*96, 64*64, 48*48 and 32*32 pixel bitmaps). Ideally this should be fixed.

The second issue I have, which is kind of separate, is that it's pretty inconvenient to add a custom cursor in a C# UWP app. One has to follow the steps in the last comment in this thread. It would be good if it wasn't necessary to create a separate project to do this.

(In case you are wondering, I'm trying to add an eye dropper cursor for picking a color from an image).

Felix-Dev commented 3 years ago

Linking WinUI's Proposal: Improved Cursor APIs which mentions these issues.

stevewri commented 3 years ago

This may end up requiring work in multiple components (WinUI, core input and low-level cursor support). @feisu, are you a good owner for the low-level cursor support?