Question

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 ?

Was it helpful?

Solution

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;

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top