{"record":{"id":"3356de76a3a6dba5","repo":"dotnet/wpf","slug":"sr-storyboard-unrecognizedhandoffbehavior-unrecognized","errorCode":null,"errorMessage":"SR.Storyboard_UnrecognizedHandoffBehavior (unrecognized HandoffBehavior value)","messagePattern":"SR\\.Storyboard_UnrecognizedHandoffBehavior \\(unrecognized HandoffBehavior value\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/BeginStoryboard.cs","lineNumber":80,"sourceCode":"    /// </summary>\n    [DefaultValue(HandoffBehavior.SnapshotAndReplace)]\n    public HandoffBehavior HandoffBehavior \n    {\n        get\n        {\n            return _handoffBehavior;\n        }\n        set\n        {\n            ThrowIfSealed();\n\n            if(HandoffBehaviorEnum.IsDefined(value)) \n            {\n                _handoffBehavior = value;\n            }\n            else\n            {\n                throw new ArgumentException(SR.Storyboard_UnrecognizedHandoffBehavior);\n            }\n        }\n    }\n\n    /// <summary>\n    ///     The name to use for referencing this Storyboard.  This named is used \n    /// by a control action such as pause and resume.  Defaults to null, which\n    /// means this storyboard is not going to be interactively controlled.\n    /// </summary>\n    // Null == no interactive control == \"Fire and Forget\"\n    [DefaultValue(null)]\n    public string Name\n    {\n        get\n        {\n            return _name;\n        }\n        set","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/BeginStoryboard.cs#L62-L98","documentation":"BeginStoryboard.HandoffBehavior throws ArgumentException with SR.Storyboard_UnrecognizedHandoffBehavior when the setter receives a value not defined in the HandoffBehavior enum. Only SnapshotAndReplace and Compose are accepted; any out-of-range cast value fails HandoffBehaviorEnum.IsDefined.","triggerScenarios":"Assigning an invalid value to BeginStoryboard.HandoffBehavior, typically via an unchecked cast like (HandoffBehavior)99 or bad XAML markup extension output, during property set on the BeginStoryboard object.","commonSituations":"XAML with a malformed HandoffBehavior attribute value, or programmatic animation setup where a variable of the wrong value is cast to HandoffBehavior.","solutions":["Use only HandoffBehavior.SnapshotAndReplace or HandoffBehavior.Compose.","Validate any dynamically obtained value with Enum.IsDefined(typeof(HandoffBehavior), value) before assigning.","Fix the XAML attribute to a valid enum name if set from markup."],"exampleFix":"// before\nbeginStoryboard.HandoffBehavior = (HandoffBehavior)userValue;\n// after\nvar behavior = (HandoffBehavior)Enum.Parse(typeof(HandoffBehavior), userString);\nif (!Enum.IsDefined(typeof(HandoffBehavior), behavior)) behavior = HandoffBehavior.SnapshotAndReplace;\nbeginStoryboard.HandoffBehavior = behavior;","handlingStrategy":"type-guard","validationCode":"if (!Enum.IsDefined(typeof(HandoffBehavior), value))\n    throw new ArgumentException($\"Invalid HandoffBehavior: {value}\");","typeGuard":"bool IsValidHandoffBehavior(object v) => v is HandoffBehavior hb && Enum.IsDefined(typeof(HandoffBehavior), hb);","tryCatchPattern":"try { beginStoryboard.HandoffBehavior = behavior; }\ncatch (ArgumentException ex) { beginStoryboard.HandoffBehavior = HandoffBehavior.SnapshotAndReplace; }","preventionTips":["Only assign enum members, never raw casts of external integers","Use Enum.TryParse when converting strings from XAML/config to HandoffBehavior","Prefer HandoffBehavior.SnapshotAndReplace as the default"],"tags":["wpf","animation","enum","csharp"],"backgroundTag":"invalid-enum-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}