0

I want to override Mouse cursor on a button's MouseLeftButtonDown event. Overriding with standard cursor has no problem and it is something like as below:

Mouse.OverrideCursor = Cursors.Arrow;

Now, I want to override with some custom cursor. So, I tried doing as below:

I have added the MyCursor.cur to my project and tried overriding the cursor as below.

var uriSource = new Uri("../MyCursor.cur", UriKind.Relative);
Mouse.OverrideCursor = new Cursor(uriSource.ToString());//Exception is thrown saying Absolute path is not valid.

I hope I was doing something wrong in getting the path of ".cur".

Could anyone please let me know the right way of achieving this.

Siva
  • 1,281
  • 2
  • 19
  • 41

1 Answers1

0

See this answer here SO Answer. Unfortunately the link within the answer seems to be dead, however there are still some relevant bits within the answer itself, e.g.:

If you need to load the cursor from a relative path or from a resource packed with your assembly, you will need to get a stream from the file and pass it in to the Cursor(Stream cursorStream) constructor. Annoying but true.

Community
  • 1
  • 1
Josh
  • 697
  • 7
  • 18