Silverlight custom cursor
In fact, it is very easy to set the cursor to the none value during the load, draw something at the front end, just follow when the mouse moves
< Rectangle Width = "20" Height = "20" X: Name = "Cursor" >
< Rectangle. triggers >
< Eventtrigger Routedevent = "Canvas. Loaded" >
< Beginstoryboard >
< Storyboard >
< Doubleanimation
Storyboard. targetname = "Rotate" Storyboard. targetproperty = "Angle"
By = "360" Duration = "00:00:03" Repeatbehavior = "Forever" />
</ Storyboard >
</ Beginstoryboard >
</ Eventtrigger >
</ Rectangle. triggers >
< Rectangle. rendertransform >
< Rotatetransform X: Name = "Rotate" Centerx = "10" Centery = "10" />
</ Rectangle. rendertransform >
< Rectangle. Fill >
< Lineargradientbrush >
< Gradientstop Color = "White" Offset = "0" />
< Gradientstop Color = "Red" Offset = ". 5" />
< Gradientstop Color = "Black" Offset = "1" />
</ Lineargradientbrush >
</ Rectangle. Fill >
</ Rectangle >
Public Void Page_loaded ( Object O, eventargs E) {
//Required to initialize Variables
Initializecomponent ();
This. Cursor=Cursors. None;
} Public Void Onmousemove ( Object Sender, mouseeventargs E) {
Double X = E. getposition ( This ). X;
Double Y = E. getposition ( This ). Y;
If (X <= 20 | X > = This . Width - 20 | Y <= 20 | Y > = This . Height - 20 )
This . Cursor. Visibility = Visibility. collapsed;
Else
This . Cursor. Visibility = Visibility. visible;
This . Cursor. setvalue < Double > (Canvas. leftproperty, X );
This . Cursor. setvalue < Double > (Canvas. topproperty, y );
}