繁体   English   中英

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.GeocoordinateWindows.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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM