SIGN UP MEMBER LOGIN:    
ARTICLE

Creating Custom Cursor in Silverlight

Posted by Praveen Kumar Articles | Silverlight with C# May 06, 2009
In this article we will see how to create and use it in our silverlight application.
Reader Level:
Download Files:
 


In this article we will see how to create and use it in our silverlight application.

For this example I have created the startup icon as the custom cursor in silverlight.

To create this cursor, I have used "Expression Design" as my designing tool.

1.gif

I have created this design using circle and four paths. Then I have exported this design as a jpeg file.
Now create an application in Silverlight. Add the above created image in the project. Now drag the image to the workarea and named the image as "cc".

2.gif

Now right click on the LayoutRoot and change the layout type as Canvas.
Now add an event handler in the "MouseMove" event to the LayoutRoot by clicking the Events button in the Properties panel. Here name of event handler is "cursormove".

3.gif

Add the following namespace in the code behind file(if not there already).

using System.Windows.Input;

Now in the event handler "cursormove", I have added the following code.

private void cursormove(object sender, MouseEventArgs e)
{
    Point pt = e.GetPosition(null);
    Cursor = Cursors.None;
    Canvas.SetTop(cc, pt.Y);
    Canvas.SetLeft(cc, pt.X);
}

That's it, now test your application by pressing the F5 button.

The output will be as follows

4.gif

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor