Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1531
Set GeographicPolylineSeries color programmatically
posted

Hello,

I have several GeographicPolylineSeries objects which I want to plot on a XamGeographic map, but I need to be able to set the color of each series programmatically.

I was hoping to do something like this:

     Style style = new Style();

     style.Setters.Add(new Setter(GeographicPolylineSeries.BrushProperty, Brushes.Red));

     ...

     GeographicPolylineSeries polySeries = new GeographicPolylineSeries();

     polySeries.ShapeStyle = style;

     ...

     DataMap.Series.Add(polySeries);

This obviously does not work.  Through XAML, I've been able to "hard-code" a series color using the "Stroke" property, but I don't see where that property is exposed anywhere as a dependency property to supply to the style's setters object.  Is there something I'm missing or some other preferred method for doing this?

Thanks, Steve

 

 

Parents
  • 2180
    Verified Answer
    Offline posted

    Hi Steve,

    The easiest way to set the color of the GeographicPolylineSeries is to set its Outline property:

    polySeries.Outline = Brushes.Red;

    You can use also the ShapeStyle but the style target type should be Path, not GeographicPolylineSeries since Paths are used to draw the shapes of the series. Here is the code:

    Style style = new Style();

    style.Setters.Add(new Setter(Path.StrokeProperty, Brushes.Red));

    GeographicPolylineSeries polySeries = new GeographicPolylineSeries();

    polySeries.ShapeStyle = style;

    Thanks,

    Diyan Dimitrov

Reply Children