// XAML Map Control - http://xamlmapcontrol.codeplex.com/ // © 2015 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) using System.Linq; using System.Windows.Media; namespace MapControl { public partial class MapPolyline { public MapPolyline() { Data = new StreamGeometry(); } protected override void UpdateData() { var geometry = (StreamGeometry)Data; if (ParentMap != null && Locations != null && Locations.Any()) { using (var context = geometry.Open()) { var points = Locations.Select(l => ParentMap.MapTransform.Transform(l)); context.BeginFigure(points.First(), IsClosed, IsClosed); context.PolyLineTo(points.Skip(1).ToList(), true, false); } geometry.Transform = ParentMap.ViewportTransform; } else { geometry.Clear(); geometry.ClearValue(Geometry.TransformProperty); } } } }