0

我正在编写一个简单的 windows phone 7.5 本地化应用程序。

我已将默认图钉模板更改为:

 <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>

当我单击图钉时,我处理事件并将所选图钉的模板更改为:

        <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>

这样我就可以显示一些信息和一些命令。结果完美运行,并显示一个包含我所有自定义数据的黑色矩形。

但是,其他引脚(默认模板)与矩形重叠并出现在我选择的引脚顶部并隐藏信息。

有没有人想强制选择的引脚模板始终位于其他引脚之上?

有关我地图的 XAML 的信息:

 <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>
4

2 回答 2

1

我能够解决此默认行为的唯一方法是删除原始引脚,然后使用不同的模板在相同位置添加一个新引脚。
新添加的引脚出现在 Z-Order 的顶部,但是一旦创建,我就无法更改现有引脚的 Z-Order。

还记得在用户单击另一个引脚时“重置”处于选定状态的任何引脚。

于 2012-10-03T09:57:25.590 回答
0

我想这应该可以帮助你:http ://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/c4055dba-3efd-4bf7-98b3-cd8e24d175ea

于 2012-10-03T09:42:33.643 回答