Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPFVB.NET
Hi,
 
In one of the WPF application, I am setting cursor to Wait cursor with below code
 
Mouse.OverrideCursor = Windows.Input.Cursor.Wait
 
after some time I want to set it to default cursor.
 
Though in MSDN cursor class (System.Windows.Input.Cursor) default property is mentioned
 
I am not able to use it.
 
Is there any way to set the default cursor like we set in the form using Windows.Forms.Cursors.Default.
 

 

Appreciate the answer.
 
Vijay
Posted 19-Nov-12 14:31pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can do this:
System.Windows.Input.Cursor saveCursor = someFrameworkElement.Cursor;
someFrameworkElement.Cursor = Cursors.WaitCursor;
and, at the end
someFrameworkElement.Cursor = saveCursor;
 
Please also see my article where I show how to use using statement based in System.IDisposable to do such things:
Hourglass Mouse Cursor Always Changes Back to its Original Image. How?[^].
 
If works for both System.Windows.Forms and WPF.
 
Also, see more generic alternative to my solution, which I gladly accepted: Hourglass Mouse Cursor Always Changes Back to its Original Image. How?[^].
 
Is is based on the RAII pattern: http://en.wikipedia.org/wiki/RAII[^].
 
This is something which is very good to know.
 
Good luck,
—SA
  Permalink  
v3
Comments
Vijay hit at 19-Nov-12 21:52pm
   
Hi Sergey, Thanks for the answer. Cursor.Current = Cursors.Default din't worked as Default is not appearing in cusors. I am getting error like default is not a member of cursors. But your blog helped a lot. I just used your technique of setting Previous and it worked well. Dim previous as system.windows.input.cursor = me.cursor me.Cursor = cursors.wait after my task I reset the cursor by me.cursor = previous. Thanks again, Vijay
Sergey Alexandrovich Kryukov at 19-Nov-12 23:37pm
   
Great. Sorry, I messed up a bit, edited the sample; thank you for fixing it. You are very welcome. Good luck, call again. --SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 696
1 OriginalGriff 478
2 Tadit Dash 400
3 sanket saxena 337
4 Peter Leow 228
0 Sergey Alexandrovich Kryukov 11,890
1 OriginalGriff 7,335
2 Peter Leow 5,003
3 Abhinav S 3,943
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web02 | 2.8.140421.2 | Last Updated 16 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid