View in MAUI WPF WinUI View on GitHub

Update the orientation of a graphic using expressions based on its attributes.

Image of scene properties expressions

Use case

Instead of reading the attribute and changing the rotation on the symbol for a single graphic (a manual CPU operation), you can bind the rotation to an expression that applies to the whole overlay (an automatic GPU operation). This usually results in a noticeable performance boost (smooth rotations).

How to use the sample

Adjust the heading and pitch sliders to rotate the cone.

How it works

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

Relevant API

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

Tags

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

Sample Code

ScenePropertiesExpressions.xaml ScenePropertiesExpressions.xaml ScenePropertiesExpressions.xaml.cs
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGIS.Samples.ScenePropertiesExpressions.ScenePropertiesExpressions"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui"
xmlns:resources="clr-namespace:ArcGIS.Resources">
<Grid Style="{DynamicResource EsriSampleContainer}">
<esriUI:SceneView x:Name="MySceneView" Style="{DynamicResource EsriSampleGeoView}" />
<Border Style="{DynamicResource EsriSampleControlPanel}">
<Grid ColumnDefinitions="auto,*"
ColumnSpacing="5"
RowDefinitions="auto,auto"
RowSpacing="5">
<Label Grid.Row="0"
Grid.Column="0"
Text="Heading:"
VerticalTextAlignment="Center" />
<Slider x:Name="HeadingSlider"
Grid.Row="0"
Grid.Column="1"
Maximum="360"
Minimum="0" />
<Label Grid.Row="1"
Grid.Column="0"
Text="Pitch:"
VerticalTextAlignment="Center" />
<Slider x:Name="PitchSlider"
Grid.Row="1"
Grid.Column="1"
Maximum="90"
Minimum="-90" />
</Grid>
</Border>
</Grid>
</ContentPage>