{"record":{"id":"f1e00950d3987cd7","repo":"dotnet/wpf","slug":"sr-format-sr-markupextensionbadstatic-member","errorCode":null,"errorMessage":"SR.Format(SR.MarkupExtensionBadStatic, Member)","messagePattern":"SR\\.Format\\(SR\\.MarkupExtensionBadStatic, Member\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Markup/StaticExtension.cs","lineNumber":65,"sourceCode":"                if (value != null)\n                {\n                    return value;\n                }\n            }\n            else\n            {\n                value = SystemResourceKey.GetSystemResourceKey(Member);\n                if (value != null)\n                {\n                    return value;\n                }\n\n                // Validate the _member\n\n                int dotIndex = Member.IndexOf('.');\n                if (dotIndex < 0)\n                {\n                    throw new ArgumentException(SR.Format(SR.MarkupExtensionBadStatic, Member));\n                }\n\n                // Pull out the type substring (this will include any XML prefix, e.g. \"av:Button\")\n\n                string typeString = Member.Substring(0, dotIndex);\n                if (typeString == string.Empty)\n                {\n                    throw new ArgumentException(SR.Format(SR.MarkupExtensionBadStatic, Member));\n                }\n\n                // Get the IXamlTypeResolver from the service provider\n\n                ArgumentNullException.ThrowIfNull(serviceProvider);\n\n                IXamlTypeResolver xamlTypeResolver = serviceProvider.GetService(typeof(IXamlTypeResolver)) as IXamlTypeResolver;\n                if (xamlTypeResolver == null)\n                {\n                    throw new ArgumentException(SR.Format(SR.MarkupExtensionNoContext, GetType().Name, \"IXamlTypeResolver\"));","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Markup/StaticExtension.cs#L47-L83","documentation":"StaticExtension.ProvideValue requires the Member string in \"Type.Member\" form (optionally with an XML prefix like \"av:Button.Member\") so it can split the declaring type from the member name. If Member contains no dot (dotIndex < 0), the split is impossible and it throws ArgumentException (SR.MarkupExtensionBadStatic, Member).","triggerScenarios":"{x:Static MyValue} or {x:Static ns:MyValue} — a Member string without a '.' separating type and member names — passed to ProvideValue during XAML parsing.","commonSituations":"Confusing x:Static with StaticResource and writing just a key/name; omitting the declaring type of the static member; refactoring that dropped the \"Type.\" qualifier from the markup.","solutions":["Use the full \"prefix:Type.Member\" form: {x:Static sys:Environment.TickCount} or {x:Static local:AppColors.BackgroundBrush}","Verify the referenced member is a public static field or property on the named type","If you meant a resource lookup, use {StaticResource key} instead of x:Static"],"exampleFix":"<!-- before: no dot -> ArgumentException -->\n<TextBlock Text=\"{x:Static AppTitle}\" />\n\n<!-- after: Type.Member form -->\nxmlns:local=\"clr-namespace:MyApp\"\n<TextBlock Text=\"{x:Static local:AppConstants.AppTitle}\" />","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(member) || !member.Contains('.'))\n{\n    throw new ArgumentException(\n        $\"'{member}' is not valid for x:Static; use the form 'prefix:Type.Member'.\",\n        nameof(member));\n}","typeGuard":"static bool IsWellFormedStaticMember(string member)\n    => !string.IsNullOrEmpty(member) && member.IndexOf('.') > 0;","tryCatchPattern":"try\n{\n    value = ext.ProvideValue(serviceProvider);\n}\ncatch (ArgumentException ex)\n{\n    // Member lacked the required 'Type.Member' dot form\n    ReportXamlError($\"Bad x:Static member: {ex.Message}\", ex);\n}","preventionTips":["Always write x:Static as {x:Static prefix:Type.Member} — the dot is mandatory","If you only have a key/name, you probably want {StaticResource key}, not x:Static","After refactors, search markup for x:Static usages that lost their Type. qualifier"],"tags":["wpf","xaml","markup-extension","format"],"backgroundTag":"invalid-argument-format","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"}