ArcGIS Runtime SDK for .NET Samples

ArcGIS token challenge

Loading

Code

<UserControl x:Class="ArcGISRuntime.UWP.Samples.TokenSecuredChallenge.TokenSecuredChallenge"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:local="using:ArcGISRuntime.UWP.Samples.TokenSecuredChallenge"
             xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <UserControl.Resources>
        <local:LoadStatusToColorConverter x:Key="StatusToColor"/>
    </UserControl.Resources>
    <Grid x:Name="layoutGrid">
        <esriUI:MapView x:Name="MyMapView"/>

        <!-- Login UI -->
        <Border x:Name="loginPanel"
				Background="White" BorderBrush="Black" BorderThickness="1" 
				Margin="30" Padding="20"
				HorizontalAlignment="Center" VerticalAlignment="Top" 
				Visibility="Collapsed">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="150" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" 
                           Margin="0,0,0,8"
						   TextWrapping="Wrap" 
                           Text="{Binding ServiceUrl}" />
                <TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" 
                           Margin="0,0,0,8"
						   TextWrapping="Wrap" 
                           Text="Username and Password are user1/user1" />
                <TextBlock Grid.Row="2" Grid.Column="0" 
                           Margin="2" 
                           VerticalAlignment="Center" 
                           Text="Username" />
                <TextBox Grid.Row="2" Grid.Column="1" 
                         Margin="2" 
                         Text="{Binding UserName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                <TextBlock Grid.Row="3" Grid.Column="0" 
                           Margin="2" 
                           VerticalAlignment="Center" 
                           Text="Password" />
                <!-- For simplicity, the password is visible in this example. You can use a PasswordBox to mask the password text,
                     but it complicates data binding. See this discussion for details: http://stackoverflow.com/questions/1483892/how-to-bind-to-a-passwordbox-in-mvvm -->
                <TextBox Grid.Row="3" Grid.Column="1" 
                         Margin="2" 
                         Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                <Button Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" 
                        Margin="0,12,0,0" 
						HorizontalAlignment="Center" 
                        Content="Login and Load Layer"
						Click="LoginButtonClick" />
                <TextBlock x:Name="ErrorMessageTextBlock" 
                           Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" 
                           Margin="8,12,8,0" 
						   Foreground="Red" 
                           TextWrapping="Wrap" 
                           Text="{Binding ErrorMessage}">
                </TextBlock>
            </Grid>
        </Border>

        <!-- Layer listing with status -->
        <Border Background="White" BorderBrush="Black" BorderThickness="2" 
                Margin="30" 
                MaxWidth="500"
				HorizontalAlignment="Right" VerticalAlignment="Top">
            <StackPanel>
                <TextBlock FontSize="14" FontWeight="Bold"
                           Margin="4" 
                           Text="Map Layers (with status)" />
                <StackPanel x:Name="PublicLayerPanel" Orientation="Vertical" Margin="10,5">
                    <TextBlock Text="{Binding Name}"/>
                    <TextBlock Text="{Binding LoadStatus}" Foreground="{Binding LoadStatus, Converter={StaticResource StatusToColor}}" Margin="10,0"/>
                </StackPanel>
                <StackPanel x:Name="SecureLayerPanel" Orientation="Vertical" Margin="10,5">
                    <TextBlock Text="{Binding Name}"/>
                    <TextBlock Text="{Binding LoadStatus}" Foreground="{Binding LoadStatus, Converter={StaticResource StatusToColor}}" Margin="10,0"/>
                </StackPanel>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>


In this topic
  1. Code