dotnet/wpf · error · ValueUnavailableException

SR.Format(SR.BindingGroup_ValueUnavailable, item…

Error message

SR.Format(SR.BindingGroup_ValueUnavailable, item, propertyName)

What it means

BindingGroup.GetValue throws this ValueUnavailableException when the (item, propertyName) pair exists in the group's bookkeeping but its value cannot be provided for the current validation step — the internal lookup returned Binding.DoNothing sentinel meaning 'entry present, value unavailable'. This is the sibling case of BindingGroup_NoEntry: the binding exists but produced no value.

Solutions

  1. Use TryGetValue and treat a false return as 'value not ready yet' rather than an error.
  2. Check BindingGroup.ValidateWithoutUpdate vs UpdateSources timing — only read values at the validation stage where they are expected.
  3. If a converter returns Binding.DoNothing, ensure downstream validation rules do not require a value for that property.

Example fix

// before
object v = bindingGroup.GetValue(item, "StartDate"); // throws if unavailable

// after
if (bindingGroup.TryGetValue(item, "StartDate", out var v))
{
    // validate v
}
Defensive patterns

Strategy: try-catch

Validate before calling

object probe;
bool available = bindingGroup.TryGetValue(item, propertyName, out probe);

Try / catch

try { var v = bindingGroup.GetValue(item, propName); Validate(v); }
catch (ValueUnavailableException)
{
    // value not yet available at this validation step; defer
}

Prevention

When it happens

Trigger: Calling BindingGroup.GetValue(item, propertyName) during validation/commit when the binding's value is not yet available (e.g. the binding returned Binding.DoNothing from a converter, or the source value cannot be resolved at the current UpdateSourceTrigger stage).

Common situations: Custom ValidationRules that call GetValue during UpdateSource phase before the value has propagated; converters returning Binding.DoNothing deliberately; bindings with deferred value transfers (e.g. UpdateSourceTrigger=Explicit) evaluated too early.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/c24a6105621b47c8. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingGroup.cs:459

        /// for some reason, such as conversion failure.
        /// </exception>
        /// <Remarks>
        /// This method is intended to be called from a validation rule, during
        /// its Validate method.
        /// </Remarks>
        public object GetValue(object item, string propertyName)
        {
            object value;

            if (TryGetValueImpl(item, propertyName, out value))
            {
                return value;
            }

            if (value == Binding.DoNothing)
                throw new ValueUnavailableException(SR.Format(SR.BindingGroup_NoEntry, item, propertyName));
            else
                throw new ValueUnavailableException(SR.Format(SR.BindingGroup_ValueUnavailable, item, propertyName));
        }

        /// <summary>
        /// Find the binding that uses the given item and property, and return
        /// the value appropriate to the current validation step.
        /// </summary>
        /// <returns>
        /// The method normally returns true and sets 'value' to the requested value.
        /// If the value is not available, the method returns false and sets 'value'
        /// to DependencyProperty.UnsetValue.
        /// </returns>
        /// <Remarks>
        /// This method is intended to be called from a validation rule, during
        /// its Validate method.
        /// </Remarks>
        public bool TryGetValue(object item, string propertyName, out object value)
        {
            bool result = TryGetValueImpl(item, propertyName, out value);

View on GitHub (pinned to 81131a70a4)