Load Secure WebMap

This sample demonstrates adding data in a secure WebMap document housed via ArcGIS Online (http://www.arcgis.com) in a WPF application. The user inputs a web map, along with their user name and password, to authorize access to the web map. The input is made into a URL used to generate a token from ArcGIS.com, and once a token is returned it is added to the WebMap request using the WebMap.Token property. Then 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 Property is used to add a Map Class to the WPF application for visual display.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.LoadSecureWebMap"
            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>
        <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="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10" />
            <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="20,20,20,20">
                <TextBlock FontWeight="Bold" HorizontalAlignment="Center" Text="Enter ArcGIS.com WebMap ID, Username, Password" Foreground="Black" />
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <TextBlock Text="WebMap ID: " TextAlignment="Right" Grid.Column="0" Grid.Row="0"
                               VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="Black"/>
                    <TextBox x:Name="WebMapTextBox" Width="250" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right" Margin="0,2,0,2" Foreground="Black"/>
                    <TextBlock Text="Username: " TextAlignment="Right" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="1"
                               VerticalAlignment="Center" Foreground="Black" />
                    <TextBox x:Name="UsernameTextBox" Width="250" Grid.Column="1" Grid.Row="1" Margin="0,2,0,2" Foreground="Black"/>
                    <TextBlock Text="Password: " TextAlignment="Right" HorizontalAlignment="Left" 
                               VerticalAlignment="Center" Grid.Column="0" Grid.Row="2" Foreground="Black"/>
                    <PasswordBox x:Name="PasswordTextBox" Width="250" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="2" Margin="0,2,0,2" Foreground="Black"/>
                </Grid>
                <Button x:Name="LoadWebMapButton" Content="Load WebMap" Width="100" Margin="0,5,0,10" 
                        HorizontalAlignment="Center" Click="LoadWebMapButton_Click" Foreground="Black"/>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014