Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change mouse pointer in UWP app

Is it possible to change or even hide the mouse-pointer in a UWP app? The only thing I can find is this :

Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = null;

But in UWP, this doesn't work.

like image 711
JKoning Avatar asked Jun 22 '16 00:06

JKoning


2 Answers

Yes this can be done by settings the Window.Current.CoreWindow.PointerCursor. If you set it to null, the pointer is hidden. Otherwise you can use the CoreCursorType enumeration to set a specific system point. For instance use this to set the Arrow type:

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

You can also add custom pointers by using a resource file. For details, see this blogpost.

like image 186
Martin Tirion Avatar answered Oct 02 '22 19:10

Martin Tirion


No this is not possible to hide cursor but you can use another icons like:

  • Hand
  • Arrow
  • Cross
  • Custom
  • Hand
  • Help
  • IBeam

Use xaml Button and add PointerEntered event inside Button Control like:

<Button Name="button"  BorderThickness="2" PointerEntered="button_PointerEntered"  PointerExited="button_PointerExited">Button</Button>

and c# code:

 private void button_PointerEntered(object sender, PointerRoutedEventArgs e)
    {
        Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1);
    }
    private void button_PointerExited(object sender, PointerRoutedEventArgs e)
    {
        Windows.UI.Xaml.Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1);
    }
like image 28
Irfan Avatar answered Oct 02 '22 20:10

Irfan