{"record":{"id":"4f2dba0736dbfee0","repo":"dotnet/wpf","slug":"throw-new-invalidoperationexception-sr-format-sr","errorCode":null,"errorMessage":"throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, \"NewItemPlaceholderPosition\"));","messagePattern":"throw new InvalidOperationException\\(SR\\.Format\\(SR\\.MemberNotAllowedForView, \"NewItemPlaceholderPosition\"\\)\\);","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/CollectionViewProxy.cs","lineNumber":407,"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 = ProxiedView 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 = ProxiedView as IEditableCollectionView;\n                if (ecv != null)\n                {\n                    return ecv.CanAddNew;\n                }\n                else\n                {","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/CollectionViewProxy.cs#L389-L425","documentation":"CollectionViewProxy forwards IEditableCollectionView members to the underlying view; the NewItemPlaceholderPosition setter throws InvalidOperationException(MemberNotAllowedForView) when the proxied view does not implement IEditableCollectionView, so the placeholder position cannot be set.","triggerScenarios":"Setting (proxy as ICollectionView).NewItemPlaceholderPosition on a view that isn't editable (e.g. ListCollectionView over non-editable data, or a plain CollectionView).","commonSituations":"Sharing one proxy/control across different collection views where some support editing; setting placeholder position unconditionally in view initialization code.","solutions":["Check whether the view implements IEditableCollectionView before setting NewItemPlaceholderPosition","Ensure the source collection is an editable list (e.g. IList backed ListCollectionView)","Remove or disable placeholder-position UI when the current view is not editable"],"exampleFix":"// before\nview.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd;\n// after\nif (view is IEditableCollectionView ecv)\n    ecv.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd;","handlingStrategy":"type-guard","validationCode":"if (view is IEditableCollectionView ecv) { ecv.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd; }","typeGuard":"bool SupportsPlaceholder(ICollectionView v) => v is IEditableCollectionView;","tryCatchPattern":"try { proxy.NewItemPlaceholderPosition = value; } catch (InvalidOperationException) { /* view not editable; hide placeholder UI */ }","preventionTips":["Check IEditableCollectionView support before setting editing-related members","Bind controls to editable collections when using placeholders","React to data-source changes that swap in non-editable views"],"tags":["wpf","collectionview","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}