Silverlight Cursors

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"/>

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;

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).

This entry was posted in Code. Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">