Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for .NET

Scene properties expressions

This code sample is available for these platforms:
View Sample on GitHub

Update the orientation of a graphic using scene property rotation expressions.

How to use the sample

Use the sliders to adjust the heading and pitch properties for the graphic.

How it works

Simple renderers can dynamically update the positions of graphics using an expression. The expression relates a renderer property to one of the graphic's attribute keys.

  1. Create a new graphics overlay.
  2. Create a simple renderer and set its scene properties.
    1. Set the heading expression to [HEADING].
  3. Apply the renderer to the graphics overlay.
  4. Create a point graphic and add it to the overlay.
  5. To update the graphic's rotation, update the HEADING or PITCH property in the graphic's attributes.

Relevant API

  • GraphicsOverlay
  • SimpleRenderer
  • SceneProperties
  • SimpleRenderer.SceneProperties
  • SceneProperties.HeadingExpression
  • Graphic.Attributes

About the data

The sample shows an empty scene with a point graphic and an imagery basemap.


rotation, expression, heading, pitch, scene, 3D, symbology

Sample Code

        <esriUI:SceneView x:Name="MySceneView" />
        <Border Style="{StaticResource BorderStyle}">
                <TextBlock Text="Heading:" />
                <Slider x:Name="HeadingSlider" Minimum="0" Maximum="360" />
                <TextBlock Text="Pitch:" />
                <Slider x:Name="PitchSlider" Minimum="-90" Maximum="90" />
// 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 Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System.Drawing;

namespace ArcGISRuntime.UWP.Samples.ScenePropertiesExpressions
        "Scene properties expressions",
        "Update the orientation of a graphic using scene property rotation expressions.",
        "rotation", "expression", "heading", "pitch", "scene", "3D", "symbology")]
    public partial class ScenePropertiesExpressions
        public ScenePropertiesExpressions()

        private void Initialize()
            // Set up the scene with an imagery basemap.
            MySceneView.Scene = new Scene(Basemap.CreateImagery());
            // Set the initial viewpoint for the scene.
            MapPoint point = new MapPoint(83.9, 28.4, 1000, SpatialReferences.Wgs84);
            Camera initialCamera = new Camera(point, 1000, 0, 50, 0);
            // Create a graphics overlay.
            GraphicsOverlay overlay = new GraphicsOverlay();
            overlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
            // Add a renderer using rotation expressions.
            SimpleRenderer renderer = new SimpleRenderer();
            renderer.SceneProperties.HeadingExpression = "[HEADING]";
            renderer.SceneProperties.PitchExpression = "[PITCH]";
            // Apply the renderer to the graphics overlay.
            overlay.Renderer = renderer;
            // Create a red cone graphic.
            SimpleMarkerSceneSymbol coneSymbol = SimpleMarkerSceneSymbol.CreateCone(Color.Red, 100, 100);
            coneSymbol.Pitch = -90;
            MapPoint conePoint = new MapPoint(83.9, 28.41, 200, SpatialReferences.Wgs84);
            Graphic cone = new Graphic(conePoint, coneSymbol);
            // Add the cone graphic to the overlay.
            // Listen for changes in slider values and update graphic properties.
            HeadingSlider.ValueChanged += (sender, e) => { cone.Attributes["HEADING"] = HeadingSlider.Value; };
            PitchSlider.ValueChanged += (sender, e) => { cone.Attributes["PITCH"] = PitchSlider.Value; };