{"record":{"id":"024b7deaa89f6ed6","repo":"AvaloniaUI/Avalonia","slug":"you-can-only-set-either-nameof-keytime-or-name","errorCode":null,"errorMessage":"You can only set either {nameof(KeyTime)} or {nameof(Cue)}.","messagePattern":"You can only set either (.+?) or (.+?)\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Animation/KeyFrame.cs","lineNumber":51,"sourceCode":"        public AvaloniaList<IAnimationSetter> Setters { get; } = new AvaloniaList<IAnimationSetter>();\n\n        internal KeyFrameTimingMode TimingMode { get; private set; }\n\n        /// <summary>\n        /// Gets or sets the key time of this <see cref=\"KeyFrame\"/>.\n        /// </summary>\n        /// <value>The key time.</value>\n        public TimeSpan KeyTime\n        {\n            get\n            {\n                return _ktimeSpan;\n            }\n            set\n            {\n                if (TimingMode == KeyFrameTimingMode.Cue)\n                {\n                    throw new InvalidOperationException($\"You can only set either {nameof(KeyTime)} or {nameof(Cue)}.\");\n                }\n                TimingMode = KeyFrameTimingMode.TimeSpan;\n                _ktimeSpan = value;\n            }\n        }\n\n        /// <summary>\n        /// Gets or sets the cue of this <see cref=\"KeyFrame\"/>.\n        /// </summary>\n        /// <value>The cue.</value>\n        public Cue Cue\n        {\n            get\n            {\n                return _kCue;\n            }\n            set\n            {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Animation/KeyFrame.cs#L33-L69","documentation":"Thrown by the KeyFrame.KeyTime setter when the key frame has already had its Cue set (TimingMode == KeyFrameTimingMode.Cue). A KeyFrame can be timed by exactly one mechanism — an absolute TimeSpan KeyTime or a normalized Cue — and mixing them is disallowed to keep the timeline well-defined.","triggerScenarios":"Assigning KeyFrame.KeyTime after KeyFrame.Cue has already been assigned on the same instance (or after XAML set the cue).","commonSituations":"XAML key frame using both Cue= and KeyTime= attributes; code-behind that assigns Cue then later sets KeyTime; copy-pasting between cue- and time-based key frames.","solutions":["Use only one timing mechanism per KeyFrame: either KeyTime or Cue, not both.","If you must switch modes, create a fresh KeyFrame instead of reassigning.","Remove the conflicting Cue= attribute from XAML when using KeyTime=."],"exampleFix":"// before\nvar kf = new KeyFrame { Cue = new Cue(0.5) };\nkf.KeyTime = TimeSpan.FromSeconds(1); // throws\n\n// after\nvar kf = new KeyFrame { KeyTime = TimeSpan.FromSeconds(1) };","handlingStrategy":"validation","validationCode":"if (kf.TimingMode == KeyFrameTimingMode.Cue)\n    throw new InvalidOperationException(\"KeyFrame is cue-timed; cannot set KeyTime.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide per KeyFrame whether to use KeyTime or Cue and never mix.","Create a fresh KeyFrame when switching timing modes.","In XAML, supply only one of KeyTime= or Cue=."],"tags":["animation","configuration","keyframe","state-conflict","avalonia"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}