【问题标题】:WP 8.1 MapControl How add custom pushpin and programmatically add ItemSource?WP 8.1 MapControl 如何添加自定义图钉并以编程方式添加 ItemSource?
【发布时间】:2015-08-24 16:34:53
【问题描述】:

如何添加到我的地图控件自定义图钉? 我需要在我的别针中: 文本块和按钮

我尝试这样的事情:

<Maps:MapControl Grid.Row="2"
                    x:Name="MapControl"
                    MapServiceToken=""
                    Margin="0,0,0,0" >
                <Maps:MapItemsControl >
                    <Maps:MapItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Height="25" Text="{Binding Where}" Maps:MapControl.Location="{Binding Location}" />
                                <Button Content="MyButton" Maps:MapControl.Location="{Binding Location}" />
                            </Grid>
                        </DataTemplate>
                    </Maps:MapItemsControl.ItemTemplate>
                </Maps:MapItemsControl>
            </Maps:MapControl>

但是如何将 DataSource 或 ItemsSource 添加到我的 MapItemsControl? 我需要在后面的代码中执行此操作。

我的模特:

public class PinModel
    {
        public Geopoint Location { get; set; }
        public string Where { get; set; }
    }

以及如何做这样的事情:

List<PinModel> pins = new List<PinModel>();
MapControl.DataSource = pins?????(how can I do this?)

然后在我的地图上找到图钉。

使用 Windows Phone 8.1

Maps:MapControl
xmlns:Maps="using:Windows.UI.Xaml.Controls.Maps"

【问题讨论】:

标签: c# windows-phone-8.1


【解决方案1】:

在这里查看 Shawn Kendrot 的精彩教程:http://www.visuallylocated.com/post/2014/08/13/Bind-a-collection-of-items-to-the-Windows-Phone-MapControl.aspx

它在底部有一个示例项目链接,应该可以帮助您解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-08
    • 2014-12-18
    • 2013-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-14
    • 1970-01-01
    相关资源
    最近更新 更多