Search code examples
cursorwin-universal-appiot

Change cursor to hourglass in Win10 IoT XAML


I have a method where I am posting a tweet and would like to change the cursor on the Raspberry Pi to the hourglass whilst this is being performed. the this.Cursor is not available and I can't see how to change the cursor.


Solution

  • Probably what you're looking for is the answer here: https://social.msdn.microsoft.com/Forums/windowsapps/en-US/6628870f-9222-4785-bb0f-d5487409a7ae/uwpc-how-to-change-the-mouse-pointer-cursoricon?forum=wpdevelop

    I tried the following code in the MainPage's Loaded event handler and I got the hourglass cursor at the end:

    CoreWindow.GetForCurrentThread().PointerCursor = new CoreCursor(CoreCursorType.Wait, 13);
    

    As the forum thread says if you need to change the cursor just for a UI element you need to write some custom code to handle that.

    Here, you can find information about what other cursor types are supported and what unique identifiers are associated with them: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.core.corecursortype

    Also, a similar SO question: Change cursor in Windows Store Apps

    Hope it helps!