0
votes

I'm coding a simple windows phone 7.5 localization application.

I've changed the default pushpin template as :

 <ControlTemplate TargetType="maps:Pushpin"  x:Key="allPushpinsTemplate">
        <Grid Height="26" Width="26" Margin="-13,-13,0,0" RenderTransformOrigin="0.5,0.5" >
            <Grid.RenderTransform>
                <CompositeTransform Rotation="-45"/>
            </Grid.RenderTransform>
            <Rectangle Fill="Black" HorizontalAlignment="Center" Margin="0" Stroke="White" VerticalAlignment="Center" Height="26" Width="26"/>
            <Ellipse HorizontalAlignment="Center" Height="16" Margin="0" VerticalAlignment="Center" Fill="Red" Width="16"/>
        </Grid>
    </ControlTemplate>

When I click on a pushpin, I handle the event and change the template of the selected pin as :

        <ControlTemplate TargetType="maps:Pushpin"  x:Key="detailedPushpinTemplate">
            <Grid x:Name="ContentGrid" Background="Transparent" Margin="-4,0,0,0">
                <StackPanel >
                    <Grid Background="Black">
                        <StackPanel Margin="5,5,0,0">
                            <TextBlock  Text="{Binding Adress}" Foreground="White" />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding ZipCode}" Foreground="White" />
                                <TextBlock Text="-" Foreground="White" Padding="3,0"/>
                                <TextBlock Text="{Binding City}" Foreground="White" />
                            </StackPanel>
                            <TextBlock Text="{Binding TelStd}" Foreground="White" />
                            <TextBlock Text="{Binding Email}" Foreground="White" />
                            <StackPanel Orientation="Horizontal">
                                <Button BorderBrush="Transparent" Click="Button_Click" CommandParameter="email" ClickMode="Press">
                                    <Button.Content>
                                        <Image Source="/Images/Icons/icon-mail.png" Width="40" Height="40" />
                                    </Button.Content>
                                </Button>
                                <Button BorderBrush="Transparent" Click="Button_Click" CommandParameter="phone" ClickMode="Press">
                                    <Button.Content>
                                        <Image Source="/Images/Icons/icon-phone.png" Width="40" Height="40" />
                                    </Button.Content>
                                </Button>
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                    <Polygon Fill="Black"  Points="0,0 29,0 0,29" Width="29" Height="29" HorizontalAlignment="Left" />
                    <Grid Height="26" Width="26" Margin="-13,-13,0,0" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left">
                        <Grid.RenderTransform>
                            <CompositeTransform Rotation="-45"/>
                        </Grid.RenderTransform>
                        <Rectangle Fill="Black" HorizontalAlignment="Center" Margin="0" Stroke="White" VerticalAlignment="Center" Height="26" Width="26" />
                        <Ellipse HorizontalAlignment="Center" Height="16" Margin="0" VerticalAlignment="Center" Fill="Green" Width="16" />
                    </Grid>
                </StackPanel>
            </Grid>
    </ControlTemplate>

So that I can display some info and some commands. The result works perfectly and display a black rectangle with all my custom data.

But, the other pins (default template) overlap the rectangle and appears on the top of my selected pin and hide information.

Has anyone an idea to force the selected pin template to be always on top of the other pins ?

for information the XAML of my map :

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Canvas >
            <maps:Map ZoomBarVisibility="Visible" ZoomLevel="4" Center="46.8821,2.2697"  Name="map1" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Canvas.Top="0" Height="600" Width="460">
                <maps:MapItemsControl  x:Name="mapControl"/>
                <maps:MapItemsControl ItemsSource="{Binding Locations}" >
                    <maps:MapItemsControl.ItemTemplate>
                        <DataTemplate>
                            <maps:Pushpin Location="{Binding Location}" Template="{StaticResource allPushpinsTemplate}" MouseLeftButtonDown="Pushpin_MouseLeftButtonDown"/>
                        </DataTemplate>
                    </maps:MapItemsControl.ItemTemplate>
                </maps:MapItemsControl>
                <maps:MapLayer Name="imageLayer"/>
                </maps:Map>
            <Button Content="some action" Height="70" HorizontalAlignment="Left" Margin="0" Name="button1" VerticalAlignment="Top" Width="170"  Canvas.Left="140" />
        </Canvas>

    </Grid>
2

2 Answers

1
votes

The only way I've been able to work around this default behaviour is to remove the original pin and then add a new one in the same position with the different template.
The newly added pin appears at the top in the Z-Order but I haven't been able to alter the Z-Order of existing pins once created.

Also remember to "reset" any pins in the selected state when the user clicks on another.