{"record":{"id":"358dceaa5be4536b","repo":"dotnet/wpf","slug":"sr-format-sr-membernotallowedforview","errorCode":null,"errorMessage":"SR.Format(SR.MemberNotAllowedForView, \"NewItemPlaceholderPosition\")","messagePattern":"SR\\.Format\\(SR\\.MemberNotAllowedForView, \"NewItemPlaceholderPosition\"\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ItemCollection.cs","lineNumber":887,"sourceCode":"                if (ecv != null)\n                {\n                    return ecv.NewItemPlaceholderPosition;\n                }\n                else\n                {\n                    return NewItemPlaceholderPosition.None;\n                }\n            }\n            set\n            {\n                IEditableCollectionView ecv = _collectionView as IEditableCollectionView;\n                if (ecv != null)\n                {\n                    ecv.NewItemPlaceholderPosition = value;\n                }\n                else\n                {\n                    throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, \"NewItemPlaceholderPosition\"));\n                }\n            }\n        }\n\n        /// <summary>\n        /// Return true if the view supports <seealso cref=\"IEditableCollectionView.AddNew\"/>.\n        /// </summary>\n        bool    IEditableCollectionView.CanAddNew\n        {\n            get\n            {\n                IEditableCollectionView ecv = _collectionView as IEditableCollectionView;\n                if (ecv != null)\n                {\n                    return ecv.CanAddNew;\n                }\n                else\n                {","sourceCodeStart":869,"sourceCodeEnd":905,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ItemCollection.cs#L869-L905","documentation":"Setting ItemCollection.NewItemPlaceholderPosition throws InvalidOperationException(SR.MemberNotAllowedForView, \"NewItemPlaceholderPosition\") when the current view does not implement IEditableCollectionView (ecv == null). The member only exists when the underlying view supports transactional item editing.","triggerScenarios":"Setting items.NewItemPlaceholderPosition on a view backed by a collection view that does not implement IEditableCollectionView (e.g. a plain ListCollectionView-less source or a custom view).","commonSituations":"Assigning ItemsSource to a plain IEnumerable/Collection<T> whose default view lacks editing support; code written for an ObservableCollection-based view reused against other sources.","solutions":["Bind ItemsSource to a type whose view implements IEditableCollectionView (e.g. ObservableCollection<T> with a ListCollectionView).","Check `items.CollectionView is IEditableCollectionView` before setting the property.","Configure the view explicitly (CollectionViewSource.GetDefaultView(source) as IEditableCollectionView) and set the property on the view."],"exampleFix":"// before\nitems.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;\n// after\nif (items.CollectionView is IEditableCollectionView ecv)\n    ecv.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;","handlingStrategy":"validation","validationCode":"if (items.CollectionView is IEditableCollectionView ecv)\n    ecv.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;","typeGuard":"static bool SupportsEditing(ItemCollection c) => c.CollectionView is IEditableCollectionView;","tryCatchPattern":"try { items.NewItemPlaceholderPosition = pos; }\ncatch (InvalidOperationException) { /* view not editable; skip placeholder config */ }","preventionTips":["Check CanGroup/IEditableCollectionView capability flags before view-specific members","Bind ItemsSource to types with editable default views","Configure view features via CollectionViewSource where possible"],"tags":["wpf","itemcollection","invalidoperationexception","ieditablecollectionview"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}