wpf - Hide cursor when idle -


in wpf app, want hide cursor when hasn't moved number of seconds. if moved, want show again. ideas?

you use mousemove event :

tested code:

mytimer = new timer(3000); mytimer.autoreset = false; mytimer.elapsed += delegate { mouseext.safeoverridecursor(cursors.none); }; //hide cursor  private void myview_mousemove(object sender, mouseeventargs e) {      mytimer.stop();      mouse.overridecursor = null; //show cursor      mytimer.start(); } 

this helper dispatching call override cursor:

public static class mouseext {     public static void safeoverridecursor(cursor cursor)     {         application.current.dispatcher.invoke(new action(() =>         {             mouse.overridecursor = cursor;         }));     } } 

when timer elapses cursor hidden. when moved reappears , timer reset.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -