AvaloniaUI/Avalonia · error · ArgumentException
UpdateSourceTrigger cannot be Default.
Error message
UpdateSourceTrigger cannot be Default.
What it means
BindingExpression's constructor requires a concrete UpdateSourceTrigger. UpdateSourceTrigger.Default is a sentinel meaning 'resolve from metadata'; it must be resolved to PropertyChanged, LostFocus, or Explicit before the expression is built. Passing Default through means the resolution step was skipped.
Source
Thrown at src/Avalonia.Base/Data/Core/BindingExpression.cs:82
object? fallbackValue,
TimeSpan delay = default,
IValueConverter? converter = null,
CultureInfo? converterCulture = null,
object? converterParameter = null,
bool enableDataValidation = false,
BindingMode mode = BindingMode.OneWay,
BindingPriority priority = BindingPriority.LocalValue,
string? stringFormat = null,
object? targetNullValue = null,
AvaloniaProperty? targetProperty = null,
TargetTypeConverter? targetTypeConverter = null,
UpdateSourceTrigger updateSourceTrigger = UpdateSourceTrigger.PropertyChanged)
: base(priority, targetProperty, enableDataValidation)
{
if (mode == BindingMode.Default)
throw new ArgumentException("Binding mode cannot be Default.", nameof(mode));
if (updateSourceTrigger == UpdateSourceTrigger.Default)
throw new ArgumentException("UpdateSourceTrigger cannot be Default.", nameof(updateSourceTrigger));
if (source == AvaloniaProperty.UnsetValue)
source = null;
_source = new(source);
_mode = mode;
_nodes = nodes ?? s_emptyExpressionNodes;
_targetTypeConverter = targetTypeConverter;
_shouldUpdateOneTimeBindingTarget = _mode == BindingMode.OneTime;
if (delay != default ||
converter is not null ||
converterCulture is not null ||
converterParameter is not null ||
fallbackValue != AvaloniaProperty.UnsetValue ||
!string.IsNullOrWhiteSpace(stringFormat) ||
(targetNullValue is not null && targetNullValue != AvaloniaProperty.UnsetValue) ||
updateSourceTrigger is not UpdateSourceTrigger.PropertyChanged)View on GitHub (pinned to 11c5427268)
Solutions
- Resolve Default to a concrete value (typically UpdateSourceTrigger.PropertyChanged) before construction.
- Pass an explicit UpdateSourceTrigger.PropertyChanged (or LostFocus/Explicit) at the call site.
- Use the standard Binding object initialization path so the sentinel is resolved upstream.
Example fix
// before var expr = new BindingExpression(..., updateSourceTrigger: UpdateSourceTrigger.Default, ...); // after var resolved = trigger == UpdateSourceTrigger.Default ? UpdateSourceTrigger.PropertyChanged : trigger; var expr = new BindingExpression(..., updateSourceTrigger: resolved, ...);
Defensive patterns
Strategy: validation
Validate before calling
// Resolve Default before constructing a BindingExpression.
UpdateSourceTrigger ResolveTrigger(UpdateSourceTrigger t) =>
t == UpdateSourceTrigger.Default ? UpdateSourceTrigger.PropertyChanged : t; Type guard
static bool IsConcreteTrigger(UpdateSourceTrigger t) => t != UpdateSourceTrigger.Default;
Prevention
- Resolve UpdateSourceTrigger.Default to PropertyChanged (or LostFocus) before construction.
- When wrapping Binding, use the framework's init path that resolves the sentinel.
When it happens
Trigger: Directly constructing a BindingExpression with updateSourceTrigger == UpdateSourceTrigger.Default, or a binding builder that forwards the unresolved sentinel.
Common situations: A custom binding wrapper or compiled-binding helper that does not run the trigger-resolution step; framework version change altering where Default is resolved.
Related errors
- Binding mode cannot be Default.
- {this} already has an owner.
- Expected '{open}'.
- StorageItem is not a file
- StorageItem is not a writeable file
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/aae350b77f8458ba.
Report an issue: GitHub.