C# 点击Bingmap上的图钉显示另一个图钉WP7
有多个图钉。如果我们点击一个图钉,将显示另一个图钉,其中包含windows phone c#中的图像和两个文本块控件的动态数据模板。请帮忙C# 点击Bingmap上的图钉显示另一个图钉WP7,c#,xaml,windows-phone-7,windows-phone-7.1,bing-maps,C#,Xaml,Windows Phone 7,Windows Phone 7.1,Bing Maps,有多个图钉。如果我们点击一个图钉,将显示另一个图钉,其中包含windows phone c#中的图像和两个文本块控件的动态数据模板。请帮忙 <my:Map HorizontalAlignment="Stretch" Name="ServiceMap" VerticalAlignment="Stretch" MapPan="ServiceMap_MapPan"> <my:MapItemsControl x:Name="mapControl" Margin="0,0,0,4
<my:Map HorizontalAlignment="Stretch" Name="ServiceMap" VerticalAlignment="Stretch" MapPan="ServiceMap_MapPan">
<my:MapItemsControl x:Name="mapControl" Margin="0,0,0,44" /></my:Map>
<phone:PhoneApplicationPage.Resources>
<ControlTemplate x:Key="PushpinControlTemplate1" TargetType="my:Pushpin">
<Grid Name="contentGrid" Width="40" Height="75" HorizontalAlignment="Center" VerticalAlignment="Center">
<Image x:Name="Layer_1" Height="75" Source="/Images/CurrentLoc.png"/>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="PushPinTemplate2" TargetType="my:Pushpin">
<Grid Name="contentGrid" HorizontalAlignment="Center" VerticalAlignment="Center" Background="Silver" Opacity="0.7">
<Image Name="imgPin" Source="/Images/maponinemarker.png" Height="50" Width="50"> </Image>
<TextBlock Text="{Binding Id}" Margin="6,0" FontSize="24" Name="txtId"></TextBlock>
<TextBlock Text="{Binding Name}" Margin="50,50,50,50" FontSize="24"></TextBlock>
</Grid>
</ControlTemplate>
第一个图钉显示正确。点击第一个图钉时,如何使用PushpinControlTemplate2模板显示第二个图钉。如果我们将值分配给模板,它不会被分配请您进一步解释问题,并尽可能提供代码示例?我有n个图钉要动态加载到地图控件中。如果轻敲一个图钉,则会显示另一个图钉,该图钉的内容为堆叠面板。stackpanel具有绑定控件,如textblock和image。如果您进行搜索,有很多示例代码可以处理此问题。请展示您迄今为止的工作情况-您尝试过什么,什么不起作用,etc@NeilTurner编辑了这个问题。请查看
Pushpin pin = new Pushpin();
pin.Location = e.Position.Location;
pin.Template = (ControlTemplate)(this.Resources["PushpinControlTemplate1"]);
mapControl.Items.Add(pin);
pin.Tap+=(s,tapEve)=>
{
Pushpin contentPin = new Pushpin();
contentPin.Location = e.Position.Location;
contentPin.Template = (ControlTemplate)(this.Resources["PushpinControlTemplate2"]);
MapView.Children.Add(contentPin);
};