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
pushpa asked 3 weeks 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
{
    InitializeComponent();
    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
Fernando answered 3 weeks ago
Your Answer

5 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com