Click here to Skip to main content
13,089,209 members (66,451 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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.

Posted 19-Nov-12 14:31pm
Rate this: bad
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:[^].

This is something which is very good to know.

Good luck,
Vijay hit 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 = me.cursor
me.Cursor = cursors.wait

after my task I reset the cursor by
me.cursor = previous.

Thanks again,
Sergey Alexandrovich Kryukov 19-Nov-12 23:37pm
Sorry, I messed up a bit, edited the sample; thank you for fixing it.
You are very welcome.
Good luck, call again.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You might use an extension method in a public static class

public static void UseWaitCursor(this FrameworkElement fel)
            fel.Dispatcher.InvokeAsync(() => { Mouse.OverrideCursor=null; }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);

Then its easy like:

 private void MainWindowLoaded(object sender, RoutedEventArgs e)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 4 Jun 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100