Load Dynamically

This sample demonstrates adding data in a WebMap document housed via ArcGIS Online (http://www.arcgis.com) in a WPF application. The WebMap.GetMapAsync Method call takes a Globally Unique Identifier (GUID) for the WebMap service provided by ArcGIS Online to obtain the geographic data layers. The WebMap’s GetMapCompletedEventArgs.Map.Layers Property is used to obtain all of the individual Layer objects and then add them dynamically to the existing Map Control that was defined in XAML via the Map.LayerCollection.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LoadWebMapDynamically"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" >
        <Grid.Resources>
            <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                <LinearGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                        <SkewTransform CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </LinearGradientBrush.RelativeTransform>
                <GradientStop Color="#FF145787" Offset="0.16"/>
                <GradientStop Color="#FF3D7FAC" Offset="0.502"/>
                <GradientStop Color="#FF88C5EF" Offset="0.984"/>
            </LinearGradientBrush>
        </Grid.Resources>
        <esri:Map x:Name="MyMap" />
        <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0">
            <Rectangle Stroke="Gray"  RadiusX="10" RadiusY="10" Fill="{StaticResource PanelGradient}" Margin="0,0,0,5" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="White" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,0,10" HorizontalAlignment="Left" Width="359.257" />
            <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0,20,30,20">
                <TextBlock FontWeight="Bold" HorizontalAlignment="Center" Text="Enter ArcGIS.com WebMap ID" Foreground="Black"/>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" >
                    <TextBlock Text="WebMap ID: " TextAlignment="Right" 
                               VerticalAlignment="Center" Margin="30,0,0,0" Foreground="Black"/>
                    <TextBox x:Name="WebMapTextBox" Text="00e5e70929e14055ab686df16c842ec1" Width="250"/>
                </StackPanel>
                <Button x:Name="LoadWebMapButton" Content="Load WebMap" Width="100" Margin="0,5,0,10" 
                        HorizontalAlignment="Center" Click="LoadWebMapButton_Click" />
                <TextBlock TextDecorations="underline" Text="WebMap Item Details" FontWeight="Bold"
                           Margin="30,0,0,0" Foreground="Black"/>
                <TextBlock x:Name="WebMapPropertiesTextBox" Margin="30,0,0,0" Foreground="Black" >
                    <Run FontStyle="Italic">Title: </Run>
                    <TextBlock Text="{Binding Title}" />
                    <LineBreak />
                    <Run FontStyle="Italic">Snippet: </Run>
                    <TextBlock Text="{Binding Snippet}" />
                    <LineBreak />
                    <Run FontStyle="Italic">Owner: </Run>
                    <TextBlock Text="{Binding Owner}" />
                </TextBlock>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
Sample code usage restrictions
5/16/2014