Yan Cui
I help clients go faster for less using serverless technologies.
Of all the cursors that we come across on a daily basis, the grab and grabbing 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:
<UserControl.Resources> <ResourceDictionary> <TextBlock x:Key="CursorGrab" Cursor="Resources/Cursors/grab.cur"/> <TextBlock x:Key="CursorGrabbing" Cursor="Resources/Cursors/grabbing.cur"/> </ResourceDictionary> </UserControl.Resources>
5. Now you can retrieve the references to these cursors in code like this:
_grabCursor = ((TextBlock) Resources["CursorGrab"]).Cursor; _grabbingCursor = ((TextBlock) Resources["CursorGrabbing"]).Cursor;
Whenever you’re ready, here are 3 ways I can help you:
- Production-Ready Serverless: Join 20+ AWS Heroes & Community Builders and 1000+ other students in levelling up your serverless game. This is your one-stop shop for quickly levelling up your serverless skills.
- I help clients launch product ideas, improve their development processes and upskill their teams. If you’d like to work together, then let’s get in touch.
- Join my community on Discord, ask questions, and join the discussion on all things AWS and Serverless.
Super! No conversation and no win32 wrapper. very nice.
thanx
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?
-PJ
Many thanks for the post and the .cur files
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 :-)