Try to search your question here, if you can't find : Ask Any Question Now ?

Changing cursor to custom cursor image as a resource

HomeCategory: stackoverflowChanging cursor to custom cursor image as a resource
Avatarpushpa asked 5 months ago

I’ve been trying to get my cursor to be a custom cursor from a .cur file located in a folder in my project as a Resource. Here’s my solution layout:

  • Solution
  • WPF Application
  • WPF Class Library
    • SampleControl.xaml
    • Images
      • test_cursor.cur

test_cur.cur’s build action is set to Resource. In my class library is a UserControl at the top level which is what I want to change the cursor for. Here’s the relative code:

public partial class SampleControl: UserControl
    StreamResourceInfo streamResource = Application.GetResourceStream(new Uri("test_cursor.cur", UriKind.Relative));
    Cursor = new Cursor(streamResource.Stream);

I’ve tried a few different variations of the Uri but I always get an error Cannot locate resource 'test_cursor.cur'.

1 Answers
Best Answer
AvatarFernando answered 5 months ago
Your Answer

12 + 11 =

Popular Tags

WP Facebook Auto Publish Powered By :