AvaloniaUI/Avalonia · error · ArgumentException
This cue object's value should be within or equal to 0.0 and
Error message
This cue object's value should be within or equal to 0.0 and 1.0
What it means
Thrown by the Cue constructor when the supplied double is outside the inclusive range [0.0, 1.0]. A Cue represents a normalized position within an animation timeline, so values below 0 or above 1 are meaningless and rejected.
Source
Thrown at src/Avalonia.Base/Animation/Cue.cs:27
/// </summary>
[TypeConverter(typeof(CueTypeConverter))]
public readonly record struct Cue : IEquatable<Cue>, IEquatable<double>
{
/// <summary>
/// The normalized percent value, ranging from 0.0 to 1.0
/// </summary>
public double CueValue { get; }
/// <summary>
/// Sets a new <see cref="Cue"/> object.
/// </summary>
/// <param name="value"></param>
public Cue(double value)
{
if (value <= 1 && value >= 0)
CueValue = value;
else
throw new ArgumentException($"This cue object's value should be within or equal to 0.0 and 1.0");
}
/// <summary>
/// Parses a string to a <see cref="Cue"/> object.
/// </summary>
public static Cue Parse(string value, CultureInfo? culture)
{
string v = value;
if (value.EndsWith('%'))
{
v = v.TrimEnd('%');
}
if (double.TryParse(v, NumberStyles.Float, culture, out double res))
{
return new Cue(res / 100d);
}View on GitHub (pinned to 11c5427268)
Solutions
- Clamp the value to [0.0, 1.0] before constructing the Cue.
- Divide percentage values by 100 before passing them in.
- Use Cue.Parse for percentage strings, which handles the /100 scaling.
Example fix
// before
var cue = new Cue(50); // meant 50%
// after
var cue = new Cue(0.5);
// or
var cue = Cue.Parse("50%", CultureInfo.InvariantCulture); Defensive patterns
Strategy: validation
Validate before calling
double v = Math.Clamp(raw, 0d, 1d); var cue = new Cue(v);
Type guard
static bool IsValidCueValue(double v) => v >= 0d && v <= 1d;
Prevention
- Treat Cue values as fractions in [0,1]; divide percentages by 100.
- Clamp computed ratios before constructing a Cue.
- Prefer Cue.Parse for percentage strings.
When it happens
Trigger: Constructing new Cue(value) with value < 0.0 or value > 1.0.
Common situations: Passing a percentage (e.g. 50) instead of a fraction (0.5); computing a cue from a ratio that can exceed 1; off-by-one in derived cue math.
Related errors
- Duration value cannot be negative.
- DelayBetweenIterations value cannot be negative.
- IterationCount value cannot be larger than long.MaxValue.
- Invalid Cue string "{value}"
- Invalid value
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/3bfe1e1bb3e1e59c.
Report an issue: GitHub.