我想在我的WP 8.1应用程序中设置MapControl上的Button。问题是Button不在元素的位置,只在Map的左上角,它正在移动。绑定中的位置是Geopoint。这是我的代码:
<Maps:MapControl x:Name="MapEvent" Grid.Row="1">
<Maps:MapItemsControl ItemsSource="{Binding}">
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<Button Maps:MapControl.Location="{Binding Location}"
Maps:MapControl.NormalizedAnchorPoint="0.5,0.5"
Content="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>
</Maps:MapControl>
答案 0 :(得分:0)
以下是一些为我工作的代码的摘录:
public class PhotoInfo
{
public String Label { get; set; }
public String FileName { get; set; }
public Geocoordinate Coordinate { get; set; }
public Point NormalizedAnchorPoint { get { return new Point(0.5, 1); } }
}
我刚才提醒说,不应该Windows.Devices.Geolocation.Geocoordinate
而是Windows.Devices.Geolocation.Geopoint
。
这就是为m:MapControl.Location
绑定Coordinate.Point
<m:MapControl ZoomLevel="{Binding ZoomLevel}" Center="{Binding Center}" MapServiceToken="xxx">
<m:MapItemsControl ItemsSource="{Binding PhotoInfos}">
<m:MapItemsControl.ItemTemplate>
<DataTemplate>
<Image m:MapControl.Location="{Binding Coordinate.Point}"
Source="ms-appx:///Assets/pushpin.png"
m:MapControl.NormalizedAnchorPoint="{Binding NormalizedAnchorPoint}" Width="20" Height="45" Tapped="Image_Tapped"/>
</DataTemplate>
</m:MapItemsControl.ItemTemplate>
</m:MapItemsControl>
</m:MapControl>