Sign In Dialog With Template Online

This sample demonstrates using a templated Toolkit.SignInDialog with the IdentityManager to prompt a user for credentials. The sample contains a Map with one layer that is token-secured. The IdentityManager.Current.Challenge method is set to a custom Challenge method sets up and calls the templated SignInDialog. In the template, you can customize settings for the SignInDialog such as the look and feel, title, text contained in the dialog, error messages, and OK/Cancel buttons.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.SignInDialogWithTemplate"
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>
            <Style x:Key="SignInDialogTemplate" TargetType="esri:SignInDialog"
                     xmlns:converters="clr-namespace:ESRI.ArcGIS.Client.Toolkit.ValueConverters;assembly=ESRI.ArcGIS.Client.Toolkit">
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFFDFDFD" Offset="0" />
                            <GradientStop Color="#FFEFF1F3" Offset="0.5" />
                            <GradientStop Color="#FFCCD3D8" Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="#FFA3AEB9" Offset="0"/>
                            <GradientStop Color="#FF8399A9" Offset="0.375"/>
                            <GradientStop Color="#FF718597" Offset="0.375"/>
                            <GradientStop Color="#FF617584" Offset="1"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="HorizontalContentAlignment" Value="Left" />
                <Setter Property="VerticalContentAlignment" Value="Top" />
                <Setter Property="Cursor" Value="Arrow" />
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="Padding" Value="0" />
                <Setter Property="Margin" Value="0" />
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="5">
                                <Grid>
                                    <Grid.Resources>
                                        <converters:VisibilityConverter x:Key="visibilityConverter" />
                                    </Grid.Resources>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Row="0" Text="{Binding Title}" Margin="5,2,0,2" FontWeight="Bold"/>
                                    <!-- Body -->
                                    <StackPanel Grid.Row="1" MinHeight="50">
                                        <!-- Info about the Url -->
                                        <RichTextBox x:Name="RichTextBoxMessage" Margin="0,2" IsReadOnly="True"
                                                Background="Transparent" BorderBrush="Transparent" BorderThickness="0" 
                                                     IsTabStop="False">
                                            <FlowDocument>
                                                <Paragraph TextAlignment="Left">
                                                    A
                                                    <Bold>username</Bold> and
                                                    <Bold>password</Bold> are required to access
                                                    <Hyperlink NavigateUri="$URL" TargetName="_blank">$RESOURCENAME</Hyperlink>
                                                    on $SERVER.
                                                </Paragraph>
                                            </FlowDocument>
                                        </RichTextBox>
                                        <!-- Error message -->
                                        <Grid MinHeight="15" Margin="0,2">
                                            <Grid Background="#FFF24444" Visibility="{Binding ErrorMessage, 
                                                Converter={StaticResource visibilityConverter}}">
                                                <RichTextBox x:Name="RichTextBoxErrorMessage" IsReadOnly="True"
                                                    Background="Transparent" BorderBrush="Transparent" BorderThickness="0" 
                                                    IsTabStop="False">
                                                    <FlowDocument>
                                                        <Paragraph>
                                                            $ERRORMESSAGE
                                                            <Bold>Please try again.</Bold>
                                                        </Paragraph>
                                                    </FlowDocument>
                                                </RichTextBox>
                                            </Grid>
                                        </Grid>
                                        <!-- User name -->
                                        <TextBlock Text="Username:" Margin="0,5,0,0" />
                                        <TextBox Text="{Binding UserName, Mode=TwoWay, ValidatesOnExceptions=True, 
                                            UpdateSourceTrigger=PropertyChanged}" TabIndex="0" />
                                        <!-- Password-->
                                        <TextBlock Text="Password:"  Margin="0,10,0,0"/>
                                        <PasswordBox Password="pass.word1" TabIndex="0" />
                                    </StackPanel>
                                    <!-- Footer with OK/Cancel buttons-->
                                    <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
                                        <Grid>
                                            <Button Content="OK" Command="{Binding GenerateCredentialCommand}" Margin="5" 
                                                    Padding="5" TabIndex="2"
                                            Visibility="{Binding IsBusy, Converter={StaticResource visibilityConverter}, 
                                                ConverterParameter=reverse}"/>
                                            <Button Content="Signing in....  " Margin="5" Padding="5" IsTabStop="False"
                                            Visibility="{Binding IsBusy, Converter={StaticResource visibilityConverter}}" 
                                                    IsHitTestVisible="False" />
                                        </Grid>
                                        <Button Content="Cancel" Command="{Binding CancelCommand}" Margin="5" Padding="5" 
                                                TabIndex="3"/>
                                    </StackPanel>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <esri:Map x:Name="MyMap" UseAcceleratedDisplay="True" WrapAround="True">
            <esri:ArcGISTiledMapServiceLayer
                Url="http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer" />
            <esri:ArcGISTiledMapServiceLayer ID="SecureLayer"
                Url="http://serverapps10.esri.com/arcgis/rest/services/GulfLawrenceSecureUser1/MapServer" 
                InitializationFailed="Layer_InitializationFailed"
                Initialized="Layer_Initialized" />
        </esri:Map>
        <esri:SignInDialog x:Name="MySignInDialog" Style="{StaticResource SignInDialogTemplate}" 
                           Title="LOGIN TO ACCESS" UserName="user1" Password="pass.word1" Width="300" Height="260" />
    </Grid>
</UserControl>


Sample code usage restrictions
5/16/2014