Changing route colors in WPF

Jan 12, 2010 at 10:58 AM


Thanks for the great Gmaps project.

Q: Is there any way to change the color of the route from default navy in WPF?

I've seen there's a way, but only for Windows Forms. From what I have found it looks like the navy color is hard-coded into the library and the only way is to change the source code.

I don't have a good grasp of Dependency Properties - can it be done through them?


Kind regards,


Jan 12, 2010 at 12:06 PM

yes you can change it, (route.Shape as System.Windows.Shapes.Path).Fill = Brushes.Red;

Jan 12, 2010 at 12:33 PM

(route.Shape as System.Windows.Shapes.Path).Fill = Brushes.Red; gives me an exception (System.Windows.Markup.XamlParseException).


So far, I modified the source code adding the Brush property to the GMapMarker class and passing this Brush to CreateRoutePath() function invoked by RegenerateRouteShape() in GMapMarker class.

In the body of CreateRoutePath() I changed the line "myPath.Stroke =;" to "myPath.Stroke = brush;"

And that works. (The only problem is that I had to recompile the library)


And by the way:

1)How to achieve the red GoogleMaps marker with a shadow, like in the picture from codeproject:

2) (Important) How did you manage to make the graph from (Did you use any special library for this, like Visifire or just WPF?)

Jan 12, 2010 at 12:40 PM

..strange, it should work as i said anyway. But do you call it After shape generation?

1) just render shadow image nexto marker, check winforms demo markers



Jan 12, 2010 at 1:20 PM

Of course ;), I called it before route.RegenerateRouteShape(MainMap);

But Fill doesn't change the color. What works is Stroke: (route.Shape as System.Windows.Shapes.Path).Stroke = Brushes.Red;

So it looks like:

GMapMarker route= new GMapMarker(new PointLatLng(lat,lng));
route.Route.AddRange(Points); //(defined before)
(route.Shape as System.Windows.Shapes.Path).Stroke = Brushes.Green;
route.ZIndex = -1;


Thank you for your rapid help!


Jan 12, 2010 at 1:41 PM

welcome ;}