Select to view content in your preferred language

Can't get Graphic to show from code

693
3
10-08-2010 11:06 AM
AlexAgranov
New Contributor
I followed the sample from

http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#AddGraphics

And got it to work from XAML. Now I'm moving all that to code-behind. I've got the tiled map layer showing up, but can't get the graphic. Stepping through the code, I can see the Symbol loading properly and I'm definitely using the same coordinate as I set in the XAML but nothing shows up.           

vehicle = new Graphic()
            {
                Geometry = new MapPoint(-122.123889, 47.669444),
                Symbol = LayoutRoot.FindResource("RedMarkerSymbol") as Symbol
            };

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.Graphics.Add(vehicle);

doesn't work.
0 Kudos
3 Replies
dotMorten_esri
Esri Notable Contributor
Are you sure this doesn't return null?
Symbol = LayoutRoot.FindResource("RedMarkerSymbol") as Symbol
0 Kudos
AlexAgranov
New Contributor
I made the mistake of not allocating a Symbol object first. It's working now.
0 Kudos
Faris_TawfiqAbdelFattah
New Contributor
Hi all
I have the same problem, i check the symbol and the geometry and thier are fine, but not graphics on the map.

Faris
0 Kudos