This project has moved and is read-only. For the latest updates, please go here.

MapPolyline is not filled

Nov 11, 2013 at 8:17 PM
I am trying to add a filled Polyline to the map.
The map appears but it seems that setting the Fill Property does not have any effect.

<m:Map x:Name="MainMap" DataContext="{Binding Map, Source={StaticResource Locator}}" Grid.Column="1" Center="{Binding MapCenter, Mode=TwoWay}" ZoomLevel="{Binding Zoom, Mode=TwoWay}" >
<m:MapItemsControl ItemsSource="{Binding TestArea}" />

public ObservableCollection<MapPolyline> TestArea
            var A = new Location(){Latitude = 48, Longitude = 4};
            var B = new Location(){Latitude = 48, Longitude = 8};
            var C = new Location(){Latitude = 52, Longitude = 8};
            var D = new Location(){Latitude = 52, Longitude = 4};
            var LocCol = new LocationCollection(){A, B, C, D, A};
            var Line = new MapPolyline();
            Line.Locations = LocCol;
            Line.Stroke = new SolidColorBrush(){Color = Colors.Red};
            Line.Fill = new SolidColorBrush(){Color = Colors.Green};
            var col = new ObservableCollection<MapPolyline>();
            return col;
Nov 11, 2013 at 10:12 PM
Edited Nov 11, 2013 at 11:45 PM
MapPolyline is only filled when it is also closed. Set Line.IsClosed = true;.

Please note also that you should not have UI controls (like MapPolyline here) in a view model. Instead, a view model should contain an abstract representation of the data, which is visualized by an appropriate data template in the view.
Marked as answer by ClemensF on 11/13/2013 at 10:52 AM