Select to view content in your preferred language

Custom Cursor from image

2539
1
08-28-2012 07:03 AM
Labels (1)
DavidCaseiro
Emerging Contributor
Hello,

I am trying to change the cursor to a image as I click a button, but i can only find help in silverlight and i cant apply it to runtime.
Is it possible or you are just able to change it to the "traditional" buttons? (hand, cross, etc...)
If is possible, how can you do it?

Thank you very much.

DC
0 Kudos
1 Reply
MichaelBranscomb
Esri Frequent Contributor
Hi,

One simple approach is to just handle the mouse enter and mouse leave events on the map element and switch the cursor in those events. It needs to be a .cur file or .ani file (there are apps you can download to convert your images) and apparently it has to be referenced by absolute path too, as opposed to relative path or pack uri.

XAML:
<esri:Map x:Name="MyMap" MouseEnter="Map_MouseEnter" MouseLeave="Map_MouseLeave">
    <esri:ArcGISTiledMapServiceLayer ID="MyLayer" 
    Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
</esri:Map>


CODE:
private void Map_MouseEnter(object sender, MouseEventArgs e)
{
    this.Cursor = Cursors.None;
    Cursor cursor = new Cursor(@"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\VsGraphics\Assets\Cursors\magicwand.cur");
    this.Cursor = cursor;
}

private void Map_MouseLeave(object sender, MouseEventArgs e)
{
    this.Cursor = Cursors.Hand;
}



Cheers

Mike
0 Kudos