[英]Windows Phone 8.1 WinRT set Button location on MapControl
I want to set the Button on MapControl in my WP 8.1 app. 我想在我的WP 8.1应用程序中设置MapControl上的按钮。 The problem is the Button isn't on location of the element only is on top-left of the Map and it is moving. 问题是Button不在元素的位置,仅在Map的左上方,并且它正在移动。 Location in binding is Geopoint. 绑定中的位置是Geopoint。 Here's my code: 这是我的代码:
<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>
Here is an excerpt of some code working for me : 这是一些对我有用的代码的摘录:
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); } }
}
I just reminded that one should not bind on Windows.Devices.Geolocation.Geocoordinate
but on Windows.Devices.Geolocation.Geopoint
. 我只是提醒人们应该不绑定Windows.Devices.Geolocation.Geocoordinate
但Windows.Devices.Geolocation.Geopoint
。
This is why Binding of m:MapControl.Location
is on Coordinate.Point
这就是为什么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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.