Mapping and Location in Windows Phone: Listing 2

XAML for the MapItemsControl, which is data bound to the Cities property.

<maps:Map LogoVisibility="Collapsed"
            CopyrightVisibility="Collapsed"
            CredentialsProvider="{StaticResource Credentials}">
    <maps:Pushpin x:Name="MyLocationPushPin" Content="Here I Am!"
                    Location="{Binding CurrentLocation}" />
    <maps:MapItemsControl ItemsSource="{Binding Cities}">
        <maps:MapItemsControl.Resources>
            <DataTemplate x:Key="CityItemTemplate">
                <maps:Pushpin Location="{Binding Location}">
                    <Grid MaxHeight="30" MaxWidth="80">
                        <Image Source="{Binding ImageUrl}" Stretch="UniformToFill"/>
                        <TextBlock Text="{Binding Name}" Foreground="Black" />
                    </Grid>
                </maps:Pushpin>
            </DataTemplate>
        </maps:MapItemsControl.Resources>
        <maps:MapItemsControl.ItemTemplate>
            <StaticResource ResourceKey="CityItemTemplate"/>
        </maps:MapItemsControl.ItemTemplate>
    </maps:MapItemsControl>
</maps:Map>

About the Author

Nick Randolph runs Built to Roam, a consulting company that specializes in training, mentoring and assisting other companies build mobile applications. With a heritage in rich client applications for both the desktop and a variety of mobile platforms, Nick currently presents, writes and educates on the Windows Phone platform.

comments powered by Disqus

Featured

  • Move Over, Stack Overflow: Microsoft Launches Q&A for .NET

    Stack Overflow probably isn't worried, but Microsoft has launched its own Q&A site for all things .NET, seeking to provide a one-stop-shop for getting .NET technical questions answered by the community.

  • Developer Decries WinForms-to-Blazor Performance Degradation

    Since shipping .NET 5, Visual Studio 2019 v16.8 and more goodies recently, Microsoft has been touting speed improvements in many components -- including the red-hot Blazor project -- but some real-world developers are finding different results.

  • Google Cloud Functions Supports .NET Core 3.1 (but not .NET 5)

    Google Cloud Functions -- often used for serverless, event-driven projects -- now supports .NET, but the new support is a release behind Microsoft's latest .NET offering.

  • Binary Classification Using PyTorch: Model Accuracy

    In the final article of a four-part series on binary classification using PyTorch, Dr. James McCaffrey of Microsoft Research shows how to evaluate the accuracy of a trained model, save a model to file, and use a model to make predictions.

  • Visual Basic in .NET 5: Ready for WinForms Apps

    With the milestone .NET 5 and Visual Studio 2019 v16.8 releases now out, Microsoft is reminding Visual Basic coders that their favorite programming language enjoys full support and the troublesome Windows Forms Designer is even complete -- almost.

Upcoming Events