Windows Phone 8.1 WinRT在MapControl上设置按钮位置 [英] Windows Phone 8.1 WinRT set Button location on MapControl

查看:71
本文介绍了Windows Phone 8.1 WinRT在MapControl上设置按钮位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的WP 8.1应用程序中设置MapControl上的按钮.问题是Button不在元素的位置,仅在Map的左上方,并且它正在移动.绑定中的位置是Geopoint.这是我的代码:

I want to set the Button on MapControl in my WP 8.1 app. The problem is the Button isn't on location of the element only is on top-left of the Map and it is moving. Location in binding is 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); } }
}

我只是提醒人们,不应该在Windows.Devices.Geolocation.Geocoordinate上绑定,而应该在Windows.Devices.Geolocation.Geopoint上绑定.

I just reminded that one should not bind on Windows.Devices.Geolocation.Geocoordinate but on Windows.Devices.Geolocation.Geopoint.

这就是为什么Coordinate.Point绑定在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>

这篇关于Windows Phone 8.1 WinRT在MapControl上设置按钮位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆