2012-10-03 46 views
0

早上好。Windows Phone图钉重叠

我正在编写一个简单的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> 

回答

1

我已经能够解决此默认行为的唯一方法是删除原然后在不同模板的相同位置添加一个新的。
新添加的引脚出现在Z顺序的顶部,但我一直未能改变现有引脚的Z顺序。

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

+0

你好,感谢你的想法。当你说“删除原始图钉”时,你的意思是将它从地图上移除或从数据上下文中删除? –

+0

@SebastienRoche将其从地图上移除。由于绑定引脚的问题,我停止自动绑定它们并将它们添加到代码中。它使处理这种情况变得更容易。 –

相关问题