{"record":{"id":"8384a61df53afd61","repo":"dotnet/wpf","slug":"sr-markupextensiondynamicorbindingincollection","errorCode":null,"errorMessage":"SR.MarkupExtensionDynamicOrBindingInCollection","messagePattern":"SR\\.MarkupExtensionDynamicOrBindingInCollection","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Helper.cs","lineNumber":685,"sourceCode":"                                                                targetType.Name));\n                        }\n                    }\n                    else\n                    {\n                        // This is the Collection ContentProperty case\n                        // Example:\n                        // <DockPanel>\n                        //   <Button />\n                        //   <DynamicResource ResourceKey=\"foo\" />\n                        // </DockPanel>\n\n                        // Collection<BindingBase> used in MultiBinding is a special\n                        // case of a Collection that can contain a Binding.\n\n                        if (!typeof(BindingBase).IsAssignableFrom(markupExtension.GetType()) ||\n                            !typeof(Collection<BindingBase>).IsAssignableFrom(targetProperty.GetType()))\n                        {\n                            throw new XamlParseException(SR.Format(SR.MarkupExtensionDynamicOrBindingInCollection,\n                                                                markupExtension.GetType().Name,\n                                                                targetProperty.GetType().Name));\n                        }\n                    }\n                }\n            }\n            else\n            {\n                // This is the explicit Collection Property case\n                // Example:\n                // <DockPanel>\n                // <DockPanel.Children>\n                //   <Button />\n                //   <DynamicResource ResourceKey=\"foo\" />\n                // </DockPanel.Children>\n                // </DockPanel>\n\n                // Collection<BindingBase> used in MultiBinding is a special","sourceCodeStart":667,"sourceCodeEnd":703,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Helper.cs#L667-L703","documentation":"CheckCanReceiveMarkupExtension allows a markup extension inside a collection only when the extension is a BindingBase and the target property's type is a Collection<BindingBase> (the MultiBinding.Bindings special case). Otherwise it throws this XamlParseException naming the extension type and the collection's type.","triggerScenarios":"Placing an extension such as StaticResource or DynamicResource (not a Binding) into a collection property like MultiBinding.Bindings, or putting a Binding into a collection whose type is not Collection<BindingBase>.","commonSituations":"Adding {StaticResource} entries to MultiBinding.Bindings, custom collection properties typed as List<BindingBase> instead of Collection<BindingBase>, and XAML snippets copied between collection types.","solutions":["Use only Binding (or other BindingBase derivatives) inside MultiBinding.Bindings.","Type custom collection properties as Collection<BindingBase> if they must accept bindings.","Move non-binding extensions out of collection properties and apply them elsewhere.","Replace the extension with a concrete value instance added in code."],"exampleFix":"<!-- before -->\n<MultiBinding.Bindings>\n  <StaticResource ResourceKey=\"SomeConverterBinding\"/>\n</MultiBinding.Bindings>\n<!-- after -->\n<MultiBinding.Bindings>\n  <Binding Path=\"A\"/>\n  <Binding Path=\"B\"/>","handlingStrategy":"validation","validationCode":"static bool IsBindingCollectionProperty(System.Reflection.PropertyInfo p, object ext) =>\n    ext is System.Windows.Data.BindingBase &&\n    typeof(System.Collections.ObjectModel.Collection<System.Windows.Data.BindingBase>).IsAssignableFrom(p.PropertyType);","typeGuard":null,"tryCatchPattern":"try { Helper.CheckCanReceiveMarkupExtension(target, propertyInfo, ext); }\ncatch (XamlParseException ex) { log.Error($\"Invalid extension in collection: {ex.Message}\"); }","preventionTips":["Put only Binding-derived extensions in MultiBinding.Bindings.","Type bindable collection properties as Collection<BindingBase>.","Keep non-binding extensions on scalar dependency properties."],"tags":["wpf","xaml","markup-extension","collection"],"backgroundTag":"incompatible-source-type","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"}