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

ItemContainerStyle vs ItemTemplate for Polyline

Feb 7, 2013 at 3:55 AM
If I add the following to both the PolylineItemTemplate and the PolylineItemStyle on MainPage.xaml in the sample app:
 IsClosed="True" Fill="Green"
It only takes effect when using PolylineItemStyle.
<!-- use ItemTemplate or ItemContainerStyle alternatively -->
<!--<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
  ItemTemplate="{StaticResource PolylineItemTemplate}"/>-->
<map:MapItemsControl ItemsSource="{StaticResource Polylines}"
  ItemContainerStyle="{StaticResource PolylineItemStyle}"/>
Whereas Stroke and StrokeThickness work in both cases. Is this the expected behavior?
Coordinator
Feb 7, 2013 at 4:25 PM
Edited Feb 7, 2013 at 4:27 PM
Hi Jay,
I changed the DataTemplate and Style like shown below, and it works for all three platforms.
<DataTemplate x:Key="PolylineItemTemplate">
    <map:MapPolyline Locations="{Binding Locations}"
        Stroke="Red" StrokeThickness="3" IsClosed="True" Fill="Green"/>
</DataTemplate>
<Style x:Key="PolylineItemStyle" TargetType="map:MapItem">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="map:MapItem">
                <map:MapPolyline Locations="{Binding Locations}"
                    Stroke="Red" StrokeThickness="3" IsClosed="True" Fill="Green"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Feb 7, 2013 at 5:43 PM
AhHa! It's the same problem as this work item. If I set the initial map location to your default (<map:Location Latitude="53.5" Longitude="8.2"/>then
<DataTemplate x:Key="PolylineItemTemplate">
    <map:MapPolyline Locations="{Binding Locations}"
        Stroke="Red" StrokeThickness="3" IsClosed="True" Fill="Green"/>
</DataTemplate>
works fine. If I set the initial location to <map:Location Latitude="47.5" Longitude="-122.5"/> then the line is not displayed at all. So something about the location of the created polyline relative the map viewport at the time of creation seems to be triggering the problem.