有多个图钉。如果我们点击图钉显示另一个带有动态数据模板的图钉,其中包含图像和windows phone c#中的两个文本块控件。请帮忙。
<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>
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);
};
第一个图钉正确显示。当点击第一个图钉时,它如何使用PushpinControlTemplate2的模板显示第二个图钉。如果我们将值分配给模板,那么它就会被分配