locked
Hide Pointer/Cursor in Windows Store App RRS feed

  • Question

  • Hello

    How to Hide the pointer / cursor in windows store app? and how to show(visible) it when user moves the pointer?


    Santana George

    Wednesday, October 16, 2013 5:48 AM

Answers

  • Hi,

    To hide cursor, just use this : Window.Current.CoreWindow.PointerCursor = null;

    If you want to make it visible again later, you can store the old value and restore it.

    private readonly CoreCursor _baseCursor;
     _baseCursor = Window.Current.CoreWindow.PointerCursor;
    
     private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
    {
      Window.Current.CoreWindow.PointerCursor = _baseCursor;
    }

    Hope it helps !



    • Edited by Thomas Bovy Wednesday, October 16, 2013 6:59 AM
    • Marked as answer by Santana George Thursday, October 17, 2013 3:22 AM
    Wednesday, October 16, 2013 6:52 AM
  • This will show the cursor only during a move. One second after the move, it disappears again:

    private CoreCursor cursor = Window.Current.CoreWindow.PointerCursor;
    DispatcherTimer timer = new DispatcherTimer();
    
    public MainPage()
    {
        this.InitializeComponent();
    
        timer.Interval = new TimeSpan(0, 0, 0, 1);
        timer.Tick += Timer_Tick;
        Window.Current.CoreWindow.PointerCursor = null;
    }
    
    private void Timer_Tick(object sender, object e)
    {
        timer.Stop();
        Window.Current.CoreWindow.PointerCursor = null;
    }
    
    private void Pointer_Moved(object sender, PointerRoutedEventArgs e)
    {
        Window.Current.CoreWindow.PointerCursor = cursor;
        timer.Start();
    }

    • Marked as answer by Santana George Thursday, October 17, 2013 3:23 AM
    Wednesday, October 16, 2013 8:59 AM

All replies

  • Hi,

    To hide cursor, just use this : Window.Current.CoreWindow.PointerCursor = null;

    If you want to make it visible again later, you can store the old value and restore it.

    private readonly CoreCursor _baseCursor;
     _baseCursor = Window.Current.CoreWindow.PointerCursor;
    
     private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
    {
      Window.Current.CoreWindow.PointerCursor = _baseCursor;
    }

    Hope it helps !



    • Edited by Thomas Bovy Wednesday, October 16, 2013 6:59 AM
    • Marked as answer by Santana George Thursday, October 17, 2013 3:22 AM
    Wednesday, October 16, 2013 6:52 AM
  • This will show the cursor only during a move. One second after the move, it disappears again:

    private CoreCursor cursor = Window.Current.CoreWindow.PointerCursor;
    DispatcherTimer timer = new DispatcherTimer();
    
    public MainPage()
    {
        this.InitializeComponent();
    
        timer.Interval = new TimeSpan(0, 0, 0, 1);
        timer.Tick += Timer_Tick;
        Window.Current.CoreWindow.PointerCursor = null;
    }
    
    private void Timer_Tick(object sender, object e)
    {
        timer.Stop();
        Window.Current.CoreWindow.PointerCursor = null;
    }
    
    private void Pointer_Moved(object sender, PointerRoutedEventArgs e)
    {
        Window.Current.CoreWindow.PointerCursor = cursor;
        timer.Start();
    }

    • Marked as answer by Santana George Thursday, October 17, 2013 3:23 AM
    Wednesday, October 16, 2013 8:59 AM
  • Worked! Thanks

    Santana George

    Thursday, October 17, 2013 3:25 AM
  • Worked! Thanks.

    Santana George

    Thursday, October 17, 2013 3:25 AM
  • The pointer disappears all right but it reappears immediately and I have to use the Window.Current.CoreWindow.PointerCursor = null;

    twice to have it really invisible.

    Monday, December 30, 2013 1:21 PM