WPF – loading grab and grabbing cursors from resource

Of all the cursors that we come across on a daily basis, the grab image and grabbing image cursors are two notable absentees in the list of supported cursors in WPF/Silverlight.

So if you happen to need these two cursors as I did earlier in the day, then here’s a few easy steps to get you going:

1. Download the grab.cur and grabbing.cur files from here and here.

2. Include them in your project, under a Resources/Cursors folder, like this:


3. Make sure the Build Action for both is set to ‘Resource’ (which is similar to Embedded Resource, except Resource is intended for WPF/Silverlight and Embedded Resource is intended for older technologies):


4. You won’t be able to put them in as Resources directly, but you can put a reference to them using dummy TextBlock controls:

        <TextBlock x:Key="CursorGrab" Cursor="Resources/Cursors/grab.cur"/>
        <TextBlock x:Key="CursorGrabbing" Cursor="Resources/Cursors/grabbing.cur"/>

5. Now you can retrieve the references to these cursors in code like this:

_grabCursor = ((TextBlock) Resources["CursorGrab"]).Cursor;
_grabbingCursor = ((TextBlock) Resources["CursorGrabbing"]).Cursor;

4 thoughts on “WPF – loading grab and grabbing cursors from resource”

  1. Great post, and thanks for the cursor resources.
    Is there any particular reason that you chose to use a TextBlock over FrameworkElement–where the Cursor property is first defined–to cache the cursor references?


  2. HI there, the better solution is to use .NET built-in converter – CursorConverter.

    Just write small code:

    public static Cursor LoadCursorFromResource(string resourceName)
    CursorConverter cc = new CursorConverter();
    Cursor cursor = cc.ConvertFrom(resourceName) as Cursor;
    return cursor;

    Important thing is to set as a parameter full path to the cursor, incuding assembly name:

    e.g. /MyAssemblyExample;component/Resources/MyGreatCursor.cur

    Now You can load any cursor – including *.ani :-)

Leave a Comment

Your email address will not be published. Required fields are marked *