我正在Windows Phone 8.1 RT项目上工作,我想在点击图钉时显示信息。
<Maps:MapControl
Center="{Binding ViewStoreModel.loc, Converter={StaticResource GeoPointConvertCenter}}"
x:Name="Map"
HorizontalAlignment="Right" Margin="0,101,0,0"
VerticalAlignment="Top"
Height="539" Width="400"
ZoomLevel = "8"
LandmarksVisible = "True"
TrafficFlowVisible = "True"
PedestrianFeaturesVisible = "False"
MapServiceToken="{StaticResource MapServiceTokenString}" >
<Maps:MapItemsControl x:Name="MapIcons" ItemsSource="{Binding ViewStoreModel.loc2}" >
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate x:Name="Temp">
<StackPanel Tapped="Image_Tapped" x:Name="MyStack" Maps:MapControl.Location="{Binding Geopoint, Converter={StaticResource GeoPointConvertCenter}}"
Maps:MapControl.NormalizedAnchorPoint="{Binding Anch,
Converter={StaticResource NormalizedAnchorPointConverter}}">
<Image x:Name="MyImage" Source="{Binding BitmapImage}" />
<TextBox x:Name="DisplayInformation" Text="Adress" Visibility="Collapsed"/>
</StackPanel>
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>
</Maps:MapControl>
为了显示图钉的信息,我在图像元素上创建了一个点击事件:
private void Image_Tapped(object sender, TappedRoutedEventArgs e)
{
StackPanel s = sender as StackPanel;
TextBox text = s.FindName("DisplayInformation") as TextBox;
text.Visibility = Windows.UI.Xaml.Visibility.Visible;
}
该图钉的信息显示良好,但是当我重新录音时,我想隐藏前一个图钉的信息并显示新的图钉。
我如何浏览MapItemsControl元素以隐藏所有图钉的信息?
好了,您可以将bool(或Visibility)属性添加到ViewStoreModel.loc2数据模型中,并将其绑定到DisplayInformation的可见性。然后,在Image_Tapped中,将all设置为false,并在s.DataContext中(将绑定项目存储在何处)将此属性设置为true。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句