ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / LayerTrack Class / CreateKeyframe Method
The layer associated with the keyframe.
The time at which to insert the keyframe in the track.
A value indicating if the layer is visible.
The value of the transparency.
The transition for the transparency of the layer. In the UI the default is ArcGIS.Core.CIM.AnimationTransition.Linear.
Example Version

CreateKeyframe Method (LayerTrack)
Create a new keyframe.
Syntax

Parameters

layer
The layer associated with the keyframe.
atTime
The time at which to insert the keyframe in the track.
isVisibile
A value indicating if the layer is visible.
transparency
The value of the transparency.
transition
The transition for the transparency of the layer. In the UI the default is ArcGIS.Core.CIM.AnimationTransition.Linear.
Remarks
If a keyframe already exists at that time it will be overwritten. The time is rounded to the nearest millisecond.
Example
Create Layer Keyframe
public void CreateLayerKeyframe(Layer layer, double transparency, TimeSpan atTime)
{
  var mapView = MapView.Active;
  if (mapView != null)
    return;

  var animation = mapView.Map.Animation;
  var layerTrack = animation.Tracks.OfType<LayerTrack>().First(); //There will always be only 1 LayerTrack in the animation.
  layerTrack.CreateKeyframe(layer, atTime, true, transparency, ArcGIS.Core.CIM.AnimationTransition.Linear);
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also