dotnet/wpf · error · InvalidOperationException
SR.Format(SR.RequiresExplicitCulture, TargetProperty.Name)
Error message
SR.Format(SR.RequiresExplicitCulture, TargetProperty.Name)
What it means
BindingExpressionBase throws this InvalidOperationException when a binding that does not have an explicit ConverterCulture or Source/StringFormat-related culture set must format a value (string formatting or conversion) but the target property has no unambiguous culture. WPF refuses to guess a culture because the inherited CultureInfo (via FrameworkLanguage/FrameworkProperty attached property) can change after load, which would silently produce different formatted strings. The error names the target property so the developer knows which binding to fix.
Solutions
- Set ConverterCulture on the Binding, e.g. ConverterCulture='en-US'.
- Set the Language attribute (xml:lang) on the root element of the XAML document, e.g. Language='en-US'.
- Set FrameworkElement.LanguageProperty globally (FrameworkElement.LanguageProperty.OverrideMetadata) to a default culture.
- If the value need not be culture-formatted, use CultureInfo.InvariantCulture explicitly via ConverterCulture or a converter.
Example fix
<!-- before -->
<TextBlock Text="{Binding Price, StringFormat={}{0:C}}" />
<!-- after -->
<TextBlock Text="{Binding Price, StringFormat={}{0:C}, ConverterCulture=en-US}" /> Defensive patterns
Strategy: validation
Validate before calling
if (binding.ConverterCulture == null && textBlock.Language == null)
throw new InvalidOperationException("Binding requires explicit ConverterCulture or Language"); Try / catch
try { ApplyBinding(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("culture"))
{
logger.Warn("Binding needs explicit culture", ex);
} Prevention
- Always set xml:lang/Language on XAML root elements
- Specify ConverterCulture for any StringFormat binding
- Override FrameworkElement.LanguageProperty default app-wide for consistent culture
When it happens
Trigger: A Binding with StringFormat or a converter that formats strings, where ConverterCulture is not specified, the binding's Mode involves a transfer that requires culture-sensitive formatting, and the CultureInfo lookup yields an empty/neutral culture (typically in a compiled-XAML/binding path where XmlLanguage is not set). Thrown from BindingExpressionBase.SetupDefaultValueConverter/culture resolution path at BindingExpressionBase.cs:1271.
Common situations: Migrating to .NET Framework 4.0+ where the culture-resolution rules became stricter; XAML StringFormat bindings without ConverterCulture; strings like dates/numbers formatted differently than expected and the binding instead throws at runtime; apps with Language attribute omitted on the root element.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- SR.BindingExpressionIsDetached
- SR.ChangeSealedBinding
- SR.Format(SR.BindingConflict, SourceProperties.ElementName…
- SR.Format(SR.CannotChangeLiveShaping, "IsLiveFiltering"…
- SR.Format(SR.CannotChangeLiveShaping, "IsLiveSorting"…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/0e042dec6a143214.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpressionBase.cs:1271
// if that doesn't work, use target element's xml:lang property
if (_culture == null)
{
DependencyObject target = TargetElement;
if (target != null)
{
if (IsInTransfer && (TargetProperty == FrameworkElement.LanguageProperty))
{
// A binding for the Language property needs the value
// of the Language property. This circularity is not
// supported (bug 1274874).
if (TraceData.IsEnabled)
{
TraceData.TraceAndNotify(TraceEventType.Critical, TraceData.RequiresExplicitCulture, this,
traceParameters: new object[] { TargetProperty.Name, this });
}
throw new InvalidOperationException(SR.Format(SR.RequiresExplicitCulture, TargetProperty.Name));
}
// cache CultureInfo since requerying an inheritable property on every Transfer/Update can be quite expensive
// CultureInfo DP rarely changes once a XAML document is loaded.
// To be 100% correct, changes to the CultureInfo attached DP should be tracked
// and cause a re-evaluation of this binding.
_culture = ((XmlLanguage) target.GetValue(FrameworkElement.LanguageProperty)).GetSpecificCulture();
}
}
}
return (CultureInfo)_culture;
}
/// <summary> Culture has changed. Re-fetch the value with the new culture. </summary>
internal void InvalidateCulture()
{
_culture = DefaultValueObject;
}View on GitHub (pinned to 81131a70a4)