This project has moved. For the latest updates, please go here.

Adding a stroke/border to MapRectangle

Aug 24, 2014 at 12:28 AM
I want to add a border to the MapRectangles but I can't seem to figure out how. I've tried adding a stroke to an ItemContainerStyle and and ItemContainerTemplate. I also tried adding a Border to both of those.

Here's the style I'm currently trying out:

<Style x:Key="RectangleItemStyle" TargetType="map:MapItem">
            <Setter Property="BorderBrush" Value="Blue" />
            <Setter Property="BorderThickness" Value="10" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <map:MapRectangle Fill="#CCC0C0C0" North="{Binding North}" East="{Binding East}" West="{Binding West}" South="{Binding South}" Tapped="MapRectangle_Tapped"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
I haven't found an easy way to show a border around a MapRectangle. The only way I've found is to add a MapPolyline but I've got over 1500 shapes and the rectangles have better performance than that many polylines.

All I need to do is have Rectangles with outlines so they can be differentiated from neighboring rectangles.
Coordinator
Aug 24, 2014 at 12:10 PM
Edited Aug 24, 2014 at 12:10 PM
MapRectangle is meant to fill a rectangular area with a Brush, mainly when it serves as base class for MapImage, where the Brush is an ImageBrush. It uses RenderTransform to transform from world coordinates to viewport coordinates and would hence also visually scale any stroke. So if you want to avoid MapPolyline, you might perhaps use the base class MapPath instead and set its Data property to an appropriate RectangleGeometry.
Marked as answer by ebsanu on 8/25/2014 at 12:20 PM