Select to view content in your preferred language

Dotted line symbol from code(not markup)

621
2
12-21-2011 02:26 AM
by Anonymous User
Not applicable
Hi guys,

Ive been trying to get a symbol with a simple fill and a dotted line as border. Here is what Ive got, although it does not seem to work:

LinearGradientBrush lgBrush = new LinearGradientBrush();
            lgBrush.StartPoint = new Point(0, 0);

            GradientStop gStop1 = new GradientStop();
            gStop1.Offset = 0.0;
            gStop1.Color = Color.FromArgb(0, 0, 255, 0);
            lgBrush.GradientStops.Add(gStop1);

            GradientStop gStop2 = new GradientStop();
            gStop2.Offset = 1.0;
            gStop2.Color = Color.FromArgb(0, 0, 255, 0);
            lgBrush.GradientStops.Add(gStop2);

            //Set up default symbol
            GraphicSymbol = new SimpleFillSymbol();
            GraphicSymbol.Fill = new SolidColorBrush(Color.FromArgb(120, 100, 100, 100));
            GraphicSymbol.BorderThickness = 5;
            GraphicSymbol.BorderBrush = lgBrush;


Can anyone see what Im doing wrong? I come from the Flex side of things so still a bit wobbly on the Silverlight.

Your help would be much appreciated.

Regards
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
It's easier to do that in XAML.
You need to redefine the ControlTemplate and set teh StrokeDashArray to define the style of line you need.

There are custom symbol samples here : http://help.arcgis.com/en/webapi/silverlight/samples/SymbolGalleryWeb/start.htm (unfortunately not exactly the one you are looking for)
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You can also use 'ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol' which has a 'BorderStyle' property.

I had forgotten that class was available in the latest API version.:o
Simpler than retemplating.
0 Kudos