Silverlight Cursors

August 16th, 2008 by Palard Julien

Today just a little article about Silverlight Cursors, made because there’s no screenshots of cursors on the msdn.
So, first, how to change the cursor when hovering over a UI element ?
- Use the XAML Cursor property of this FrameworkElement :

<Grid x:Name="LayoutRoot" Background="White" Cursor="None"/>

Download this code: cursors.xml

Here is the full list and you can test them :

Then if you want to change the cursor programmatically, use the same property in this way :

using System.Windows.Input;
/*
** Cursors is a Static Class in System.Windows.Input
** defining a set of default mouse pointers
** usable with the Cursor Class
*/
myFrameworkElement.Cursor = Cursors.Arrow;

Download this code: cursors.cs

Finally, if you want to create a custom cursor, the only way i found is to set the cursor to None and load an image, following the cursor programatically (use the MouseMove event).

Leave a Reply