Click or drag to resize

SymbolLayer Class

A base class to represent symbol layers, which are the fundamental components used to build multilayer symbols.
Inheritance Hierarchy

Namespace:  Esri.ArcGISRuntime.Symbology
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
public abstract class SymbolLayer : INotifyPropertyChanged

The SymbolLayer type exposes the following members.

Public propertyCode exampleIsColorLocked
Get if the symbol layer is color locked.
Public propertyIsEnabled
Get if the symbol layer is enabled.
Public eventPropertyChanged
Occurs when a property value changes.

The available symbol layer types correspond to the primitive geometry they are designed to render: marker layers for point, stroke layers for line, and fill layers for area or polygons. Layer types, however, are not applied exclusively to the corresponding geoelement geometry type. A marker symbol layer, for example, could be applied to a polyline feature to render its vertices. Each layer type has a unique set of properties to control its display. A symbol can contain one or several symbol layers of the same or different type. A symbol used to render polygons, for example, might contain a fill symbol layer to render the polygon interior, a stroke symbol layer for rendering the polygon outline, and a marker symbol layer to render polygon vertices. A symbol to render a polyline might contain several stroke layers of varying widths. If a symbol contains a layer that cannot render the type of geometry to which it is applied, that symbol layer is ignored when rendering.

The following table lists symbol types and symbol layers:
Symbol typeTypical symbol layersRole

Point symbol

Marker layers

Draw relative to the point geometry

Polyline symbol

Marker layers

Draw at specified locations relative to the line geometry

Stroke layers

Draw relative to the line geometry

Polygon symbol

Marker layers

Draw relative to the polygon outline or in the interior, depending on placement setting

Stroke layers

Draw relative to the polygon outline

Fill layers

Draw relative to the polygon interior

Symbol and layer property interaction

Most properties are only accessible on the symbol layer. There are some properties, however, that are also exposed for the symbol as a whole. Properties such as color and size, for example, can be modified either for an individual symbol layer, or for the symbol itself. For such properties, the value provided for the symbol may have an effect on the corresponding property for the symbol layers it contains. Similarly, the property value for a multilayer symbol might be determined from the values of the individual symbol layers it contains. There are no notifications from a symbol or symbol layer when a property has been changed. If your app needs to respond to property changes in a symbol (as a result of a propagated change, for example) you will need to reread property values to identify changes.

Unknown symbol layers or properties

The multilayer symbol specification is complex and continues to evolve outside of ArcGIS Runtime. The potential exists that some symbol layers (or properties) will not expose an API or will not be known by ArcGIS Runtime. Depending on the problem encountered, ArcGIS Runtime will handle this situation in one of the following ways:

  • If ArcGIS Runtime reads a symbol that it can render, but for which no public API is exposed, the base class for the appropriate symbol layer is returned in the layer collection.
  • The multilayer symbology specification for an existing symbol layer type might be updated to include properties that are not recognized by ArcGIS Runtime. When reading such a symbol layer, ArcGIS Runtime attempts to create it with the properties it understands. The symbol layer renders, but properties that cannot be identified are ignored.
  • In the event that a new(unrecognized) symbol layer is encountered by ArcGIS Runtime, the symbol is ignored and is not added to the symbol layer collection.



Example Name: SymbolsFromMobileStyle

Combine multiple symbols from a mobile style file into a single symbol.

Code example screen shot.

// Copyright 2019 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using WinMedia = System.Windows.Media;

namespace ArcGISRuntime.WPF.Samples.SymbolsFromMobileStyle
        name: "Read symbols from mobile style",
        category: "Symbology",
        description: "Combine multiple symbols from a mobile style file into a single symbol.",
        instructions: "Select a symbol and a color from each of the category lists to create an emoji. A preview of the symbol is updated as selections are made. The size of the symbol can be set using the slider. Click the map to create a point graphic using the customized emoji symbol, and click \"Reset\" to clear all graphics from the display.",
        tags: new[] { "advanced symbology", "mobile style", "multilayer", "stylx" })]
    public partial class SymbolsFromMobileStyle
        // A variable for the symbol style object.
        private SymbolStyle _emojiStyle;

        // The unique identifier (key) for the background face symbol in the mobile style.
        private readonly string _baseSymbolKey = "Face1";

        public SymbolsFromMobileStyle()

            // Call a function that will create the map and fill UI controls with symbols in a mobile style.

        private async void Initialize()
            // Create a new topographic basemap and assign it to the map view.
            Map map = new Map(BasemapStyle.ArcGISTopographic);
            MyMapView.Map = map;

            // Create a graphics overlay for showing point graphics and add it to the map view.
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Fill the symbol color combo box with some color choices.
            FaceColorComboBox.SelectedIndex = 0;

            // Get the full path to the downloaded mobile style file (.stylx).
            string mobileStyleFilePath = DataManager.GetDataFolder("1bd036f221f54a99abc9e46ff3511cbf", "emoji-mobile.stylx");

            // Call a function that will read the mobile style file and populate list boxes with symbol layers.
            await ReadMobileStyle(mobileStyleFilePath);

            // Handle the tapped event on the map view to draw point graphics with the chosen symbol.
            MyMapView.GeoViewTapped += GeoViewTapped;

        private async Task ReadMobileStyle(string stylePath)
                // Open the mobile style file at the provided path.
                _emojiStyle = await SymbolStyle.OpenAsync(stylePath);

                // Get the default style search parameters.
                SymbolStyleSearchParameters searchParams = await _emojiStyle.GetDefaultSearchParametersAsync();

                // Search the style with the default parameters to return all symbol results.
                IList<SymbolStyleSearchResult> styleResults = await _emojiStyle.SearchSymbolsAsync(searchParams);

                // Create an empty placeholder image to represent "no symbol" for each category.
                WinMedia.ImageSource emptyImage = WinMedia.Imaging.BitmapSource.Create
                    (2, 2, 96, 96,
                     new WinMedia.Imaging.BitmapPalette(new List<WinMedia.Color> { WinMedia.Colors.Transparent }),
                     new byte[4],

                // Create lists to contain the available symbol layers for each category of symbol and add an empty entry as default.
                List<SymbolLayerInfo> eyeSymbolInfos = new List<SymbolLayerInfo> { new SymbolLayerInfo("", emptyImage, "") };
                List<SymbolLayerInfo> mouthSymbolInfos = new List<SymbolLayerInfo> { new SymbolLayerInfo("", emptyImage, "") };
                List<SymbolLayerInfo> hatSymbolInfos = new List<SymbolLayerInfo>() { new SymbolLayerInfo("", emptyImage, "") };

                // Loop through the results and put symbols into the appropriate list according to category.
                foreach (SymbolStyleSearchResult result in styleResults)
                    // Get the symbol for this result.
                    MultilayerPointSymbol multiLayerSym = result.Symbol as MultilayerPointSymbol;

                    // Create a swatch image from the symbol.
                    RuntimeImage swatch = await multiLayerSym.CreateSwatchAsync();
                    WinMedia.ImageSource symbolImage = await swatch.ToImageSourceAsync();

                    // Create a symbol layer info object to represent the symbol in the list.
                    // The symbol key will be used to retrieve the symbol from the style.
                    SymbolLayerInfo symbolInfo = new SymbolLayerInfo(result.Name, symbolImage, result.Key);

                    // Add the symbol layer info to the correct list for its category.
                    switch (result.Category)
                        case "Eyes":
                        case "Mouth":
                        case "Hat":

                // Show the symbols in the category list boxes.
                EyeSymbolList.ItemsSource = eyeSymbolInfos;
                MouthSymbolList.ItemsSource = mouthSymbolInfos;
                HatSymbolList.ItemsSource = hatSymbolInfos;

                // Call a function to construct the current symbol (default yellow circle).
                Symbol faceSymbol = await GetCurrentSymbol();

                // Call a function to show a preview image of the symbol.
                await UpdateSymbolPreview(faceSymbol);
            catch(Exception ex)
                MessageBox.Show("Error reading symbols from style: " + ex.Message);

        // Handler for the tapped event on the map view.
        private async void GeoViewTapped(object sender, GeoViewInputEventArgs e)
            // Call a function to get the currently defined multilayer point symbol.
            MultilayerPointSymbol faceSymbol = await GetCurrentSymbol();

            // Create a graphic for the tapped location using the current symbol and add it to the map view.
            Graphic graphic = new Graphic(e.Location, faceSymbol);

        // An event handler for list box and combo box selection changes that will update the current symbol.
        private async void SymbolPropertyChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
            // Call a function that will construct the current symbol.
            Symbol faceSymbol = await GetCurrentSymbol();

            // Call a function to update the symbol preview.
            await UpdateSymbolPreview(faceSymbol);

        private async Task<MultilayerPointSymbol> GetCurrentSymbol()
            // If the style hasn't been opened, return.
            if (_emojiStyle == null) { return null; }

            MultilayerPointSymbol faceSymbol = null;
                // Get the key that identifies the selected eye symbol (or an empty string if none selected).
                SymbolLayerInfo eyeLayerInfo = (SymbolLayerInfo)EyeSymbolList.SelectedItem;
                string eyeLayerKey = eyeLayerInfo != null ? eyeLayerInfo.Key : string.Empty;

                // Get the key that identifies the selected mouth symbol (or an empty string if none selected).
                SymbolLayerInfo mouthLayerInfo = (SymbolLayerInfo)MouthSymbolList.SelectedItem;
                string mouthLayerKey = mouthLayerInfo != null ? mouthLayerInfo.Key : string.Empty;

                // Get the key that identifies the selected hat symbol (or an empty string if none selected).
                SymbolLayerInfo hatLayerInfo = (SymbolLayerInfo)HatSymbolList.SelectedItem;
                string hatLayerKey = hatLayerInfo != null ? hatLayerInfo.Key : string.Empty;

                // Create a list of the symbol keys that identify the selected symbol layers, including the base (circle) symbol.
                List<string> symbolKeys = new List<string>
                    _baseSymbolKey, eyeLayerKey, mouthLayerKey, hatLayerKey

                // Get a multilayer point symbol from the style that contains the selected symbol layers.
                faceSymbol = await _emojiStyle.GetSymbolAsync(symbolKeys) as MultilayerPointSymbol;

                // Loop through all symbol layers and lock the color.
                foreach (SymbolLayer lyr in faceSymbol.SymbolLayers)
                    // Changing the color of the symbol will not affect this layer.
                    lyr.IsColorLocked = true;

                // Unlock the color for the base (first) layer. Changing the symbol color will change this layer's color.
                faceSymbol.SymbolLayers.First().IsColorLocked = false;

                // Set the symbol color from the combo box.
                if (FaceColorComboBox.SelectedItem != null)
                    faceSymbol.Color = (Color)FaceColorComboBox.SelectedItem;

                // Set the symbol size from the slider.
                faceSymbol.Size = SizeSlider.Value;
            catch (Exception ex)
                MessageBox.Show("Unable to create symbol: " + ex.Message, "Exception");

            // Return the multilayer point symbol.
            return faceSymbol;

        private async Task UpdateSymbolPreview(Symbol symbolToShow)
            if (symbolToShow == null) { return; }

            // Create a swatch from the symbol with a white background.
            RuntimeImage swatch = await symbolToShow.CreateSwatchAsync(80, 80, 96, Color.White);

            // Convert the swatch to an image source and show it in the Image control.
            WinMedia.ImageSource symbolImage = await swatch.ToImageSourceAsync();
            SymbolPreviewImage.Source = symbolImage;

        // A handler for the click event on the clear graphics button.
        private void ClearGraphicsClick(object sender, RoutedEventArgs e)
            // Clear all graphics from the first (only) graphics overlay in the map view.

    // A class for storing information about a symbol layer.
    public class SymbolLayerInfo
        // An image source for a preview image of the symbol.
        public WinMedia.ImageSource ImageSrc { get; private set; }

        // The name of the symbol as it appears in the mobile style.
        public string Name { get; private set; }

        // A key that uniquely identifies the symbol in the style.
        public string Key { get; private set; }

        // Take all symbol info in the constructor.
        public SymbolLayerInfo(string name, WinMedia.ImageSource source, string key)
            Name = name;
            ImageSrc = source;
            Key = key;

    // A class that converts a System.Drawing.Color object to a solid brush for setting background color for UI controls. 
    public class ColorToSolidBrushConverter : IValueConverter
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            // Get the input value as a System.Drawing.Color.
            Color inColor = (Color)value;

            // Convert the input System.Drawing.Color to a System.Windows.Media.Color.
            WinMedia.Color outColor = WinMedia.Color.FromArgb(inColor.A, inColor.R, inColor.G, inColor.B);

            // Create a solid color brush using the color and return it.
            WinMedia.SolidColorBrush brush = new WinMedia.SolidColorBrush(outColor);
            return brush;

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            throw new NotImplementedException();
<UserControl x:Class="ArcGISRuntime.WPF.Samples.SymbolsFromMobileStyle.SymbolsFromMobileStyle"
        <local:ColorToSolidBrushConverter x:Key="ColorToBrushConverter"/>
        <esri:MapView x:Name="MyMapView"/>
        <Border Style="{StaticResource BorderStyle}" 
                Padding="0" Width="400" Height="290" 
            <Grid Grid.Column="0">
                    <RowDefinition Height="140"/>
                    <RowDefinition Height="40"/>
                    <RowDefinition Height="40"/>
                    <RowDefinition Height="40"/>
                <ListBox x:Name="EyeSymbolList"
                         Grid.Row="0" Grid.Column="0"
                            <Image Source="{Binding ImageSrc}"
                                   HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <ListBox x:Name="MouthSymbolList"
                         Grid.Row="0" Grid.Column="1"
                            <Image Source="{Binding ImageSrc}"
                                   HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <ListBox x:Name="HatSymbolList"
                         Grid.Row="0" Grid.Column="2"
                            <Image Source="{Binding ImageSrc}"
                                   HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <Slider x:Name="SizeSlider"
                        SmallChange="1" LargeChange="5"
                        Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
                        Minimum="8" Maximum="60" Value="20"/>
                <Label x:Name="SizeLabel" 
                       Grid.Row="1" Grid.Column="2">
                            <Run Text="Size:"/>
                            <Run Text="{Binding ElementName=SizeSlider, Path=Value, StringFormat={}{0:#}}"/>
                <ComboBox x:Name="FaceColorComboBox"
                          Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
                          Width="150" Height="25"
                          HorizontalAlignment="Center" VerticalAlignment="Center"
                                <Border Background="{Binding Converter={StaticResource ColorToBrushConverter}}" Height="25" Width="150"/>

                <Image x:Name="SymbolPreviewImage"
                       Grid.Row="2" Grid.Column="2" Grid.RowSpan="2"
                       Width="80" Height="80"/>
                <Button x:Name="ClearGraphicsButton"
                       Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
                       Width="140" Height="20"
                        Content="Clear graphics"
See Also


Additional Examples
Hyperlink to ExampleDescription
SymbolsFromMobileStyleCombine multiple symbols from a mobile style file into a single symbol.