27

I am changing cursor of a control in WPF.

btn.Cursor = Cursors.Wait;

After carrying out an operaton, I want to revert back to the default cursor, I am did not find any Cursors.Default, how to get the default cursor ?

3 Answers 3

58

You can override the cursor instead of setting the cursor, like this:

Mouse.OverrideCursor = Cursors.Wait;

Then when the operation is carried out, you can remove the override by setting it to null, like this:

Mouse.OverrideCursor = null;
Sign up to request clarification or add additional context in comments.

2 Comments

any difference(effect, side effect) compared to btn.Cursor?
I had to check my own WPF app and this is exactly what I do when I want to set the cursor back to "default" (arrow)
13

You are right. There is no Cursors.Default static property. But you can always set cursor of a control to null and it will restore control's default cursor.

// ...
btn.Cursor = Cursors.Wait;
// whatever... your operation.
btn.Cursor = null;
// now the Cursor is default again.

1 Comment

Works with MVVM, too
0

I think you need to store the current cursor in a variable before changing it to the Wait cursor and then set it to your cursor variable when you want to change it back.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.