Unique Value Renderer

This sample demonstrates the dynamic layers functionality of the ArcGIS Runtime by overriding the default renderers for the Cities, Highways and States feature layers (originally defined within ArcGIS for Desktop) with new UniqueValueRenderers defined via the ArcGIS Runtime client API. Crucially, this new rendering information is applied at the "server" level when rendering the map image. The user interface controls allow you to apply a new SimpleRenderer to each feature layer independently with the apppriate symbol type for the layer's geometry being used in each case: SimpleMarkerSymbol, SimpleLineSymbol or SimpleFillSymbol. The symbol properties are randomly generated by means of two utility functions which either create a random Color or a random enumeration value.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.DynamicLayersUniqueValueRenderer"
             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>
        <Grid.Resources>
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
            <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="_mapControl" Background="#FFE3E3E3">

        </esri:Map>
        <StackPanel Orientation="Vertical" Margin="10" HorizontalAlignment="Right" VerticalAlignment="Top">
            <Grid x:Name="DynamicLayersUiGrid" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,5,5,0" Width="170">
                <Rectangle Fill="{StaticResource PanelGradient}" Stroke="Gray" Margin="0,0,0,5">
                    <Rectangle.Effect>
                        <DropShadowEffect/>
                    </Rectangle.Effect>
                </Rectangle>
                <StackPanel Orientation="Vertical" VerticalAlignment="Top">
                    <Canvas Margin="5,5,5,5" Height="105">
                        <Rectangle Height="105" Width="160" RadiusX="5" RadiusY="5" Fill="#DDFFFFFF" Stroke="DarkGray"/>
                        <StackPanel>
                            <TextBlock Text="Cities:" Foreground="Black" Margin="5,5,5,5"/>
                            <ComboBox x:Name="CitiesFieldsComboBox" SelectedIndex="0" Margin="5,0,5,5" Width="150">
                                <ComboBoxItem>CLASS</ComboBoxItem>
                                <ComboBoxItem>ST</ComboBoxItem>
                                <ComboBoxItem>CAPITAL</ComboBoxItem>
                            </ComboBox>
                            <Button x:Name="ChangeCitiesRendererButton" Content="Change Renderer" Foreground="Black" 
                            Margin="5,0,5,5" Width="150" Click="ChangeCitiesRendererButton_Click" />
                            <Button x:Name="ResetCitiesRendererButton" Content="Reset Renderer" Foreground="Black" 
                            Margin="5,0,5,5" Width="150" Click="ResetCitiesRendererButton_Click" />
                        </StackPanel>
                    </Canvas>
                    <Canvas Margin="5,0,5,5" Height="105">
                        <Rectangle Height="105" Width="160" RadiusX="5" RadiusY="5" Fill="#DDFFFFFF" Stroke="DarkGray"/>
                        <StackPanel>
                            <TextBlock Text="Highways:" Foreground="Black" Margin="5,5,5,5"/>
                            <ComboBox x:Name="HighwaysFieldsComboBox" SelectedIndex="0" Margin="5,0,5,5" Width="150">
                                <ComboBoxItem>TYPE</ComboBoxItem>
                                <ComboBoxItem>ADMN_CLASS</ComboBoxItem>
                                <ComboBoxItem>ROUTE</ComboBoxItem>
                            </ComboBox>
                            <Button x:Name="ChangeHighwaysRendererButton" Content="Change Renderer" Foreground="Black" 
                             Margin="5,0,5,5" Width="150" Click="ChangeHighwaysRendererButton_Click" />
                            <Button x:Name="ResetHighwaysRendererButton" Content="Reset Renderer" Foreground="Black" 
                            Margin="5,0,5,5" Width="150" Click="ResetHighwaysRendererButton_Click" />
                        </StackPanel>
                    </Canvas>
                    <Canvas Margin="5,0,5,5" Height="105">
                        <Rectangle Height="105" Width="160" RadiusX="5" RadiusY="5" Fill="#DDFFFFFF" Stroke="DarkGray"/>
                        <StackPanel>
                            <TextBlock Text="States:" Foreground="Black" Margin="5,5,5,5"/>
                            <ComboBox x:Name="StatesFieldsComboBox" SelectedIndex="0" Margin="5,0,5,5" Width="150">
                                <ComboBoxItem>STATE_NAME</ComboBoxItem>
                                <ComboBoxItem>SUB_REGION</ComboBoxItem>
                            </ComboBox>
                            <Button x:Name="ChangeStatesRendererButton" Content="Change Renderer" Foreground="Black" 
                            Margin="5,0,5,5" Width="150" Click="ChangeStatesRendererButton_Click" />
                            <Button x:Name="ResetStatesRendererButton" Content="Reset Renderer" Foreground="Black" 
                            Margin="5,0,5,5" Width="150" Click="ResetStatesRendererButton_Click" />
                        </StackPanel>
                    </Canvas>
                    <Canvas Margin="5,0,5,5" Height="35">
                        <Rectangle Height="30" Width="160" RadiusX="5" RadiusY="5" Fill="#DDFFFFFF" Stroke="DarkGray"/>
                        <StackPanel>
                            <Button x:Name="ResetAllRenderersButton" Content="Reset All Renderers" Foreground="Black" 
                            Margin="5,5,5,5" Width="150" Click="ResetAllRenderersButton_Click" />
                        </StackPanel>
                    </Canvas>
                </StackPanel>
            </Grid>
        </StackPanel>
        <ProgressBar x:Name="MyProgressBar" IsIndeterminate="True" VerticalAlignment="Bottom" Width="200" Height="20" Margin="10" Visibility="{Binding Path=IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014