dotnet/wpf · error · ArgumentException
SR.InvalidPropertyValue formatted with (value, "Name") -…
Error message
SR.InvalidPropertyValue formatted with (value, "Name") - invalid Storyboard.Name value
What it means
BeginStoryboard.Name throws ArgumentException (SR.InvalidPropertyValue formatted with the bad value and "Name") when assigned a string that is not a valid XAML identifier name. This mirrors the validation DependencyObject.SetValueValidateParams performs; the name is used to register the storyboard for interactive control.
Solutions
- Use a valid XAML name: start with a letter or underscore, contain only letters, digits, underscores.
- Sanitize generated names (replace invalid characters, prefix with a letter) before assigning.
- Validate with System.Windows.Markup.NameValidationHelper before setting.
Example fix
// before beginStoryboard.Name = "my storyboard 1"; // after beginStoryboard.Name = "MyStoryboard1";
Defensive patterns
Strategy: validation
Validate before calling
bool IsValidXamlName(string name) =>
name != null && System.Text.RegularExpressions.Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_.]*$");
if (IsValidXamlName(candidateName)) beginStoryboard.Name = candidateName; Try / catch
try { beginStoryboard.Name = name; }
catch (ArgumentException ex) { beginStoryboard.Name = SanitizeName(name); } Prevention
- Generate names that start with a letter or underscore and use only letters/digits/underscores
- Sanitize user- or config-derived names before assigning to Name
- Test XAML with names containing spaces or digits early
When it happens
Trigger: Setting BeginStoryboard.Name to a string containing invalid identifier characters (spaces, leading digits, punctuation, non-identifier symbols) as checked by NameValidationHelper.IsValidIdentifierName.
Common situations: XAML with a BeginStoryboard Name containing spaces or starting with a digit, or programmatically generating names from user input without sanitization.
Related errors
- CannotChangeAfterSealed
- CannotChangeAfterSealed
- SR.Storyboard_UnrecognizedHandoffBehavior
- SR.Storyboard_UnrecognizedHandoffBehavior (unrecognized…
- Storyboard_UnableToFreeze
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/090e5a3b5c6a5804.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/BeginStoryboard.cs:105
/// by a control action such as pause and resume. Defaults to null, which
/// means this storyboard is not going to be interactively controlled.
/// </summary>
// Null == no interactive control == "Fire and Forget"
[DefaultValue(null)]
public string Name
{
get
{
return _name;
}
set
{
ThrowIfSealed();
if(value != null && !System.Windows.Markup.NameValidationHelper.IsValidIdentifierName(value))
{
// Duplicate the error string thrown from DependencyObject.SetValueValidateParams
throw new ArgumentException(SR.Format(SR.InvalidPropertyValue, value, "Name"));
}
// Null is OK - it's to remove whatever name was previously set.
_name = value;
}
}
private void ThrowIfSealed()
{
if (IsSealed)
{
throw new InvalidOperationException(SR.Format(SR.CannotChangeAfterSealed, "BeginStoryboard"));
}
}
// Bug #1329664 workaround to make beta 2
// Remove thread affinity when sealed, but before doing that, snapshot the
// current Storyboard value and remove *its* thread affinity too.View on GitHub (pinned to 81131a70a4)