Windows Phone 8.1 WinRT 在 MapControl 上设置按钮位置
Windows Phone 8.1 WinRT set Button location on MapControl
我想在我的 WP 8.1 应用程序中设置 MapControl 上的按钮。问题是 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>
这里是一些对我有用的代码的摘录:
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>
我想在我的 WP 8.1 应用程序中设置 MapControl 上的按钮。问题是 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>
这里是一些对我有用的代码的摘录:
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>