dotnet/wpf · error · InvalidOperationException
SR.Format(SR.MemberNotAllowedForView…
Error message
SR.Format(SR.MemberNotAllowedForView, "NewItemPlaceholderPosition")
What it means
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.
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.
Example fix
// before
items.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;
// after
if (items.CollectionView is IEditableCollectionView ecv)
ecv.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning; Defensive patterns
Strategy: validation
Validate before calling
if (items.CollectionView is IEditableCollectionView ecv)
ecv.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning; Type guard
static bool SupportsEditing(ItemCollection c) => c.CollectionView is IEditableCollectionView;
Try / catch
try { items.NewItemPlaceholderPosition = pos; }
catch (InvalidOperationException) { /* view not editable; skip placeholder config */ } Prevention
- Check CanGroup/IEditableCollectionView capability flags before view-specific members
- Bind ItemsSource to types with editable default views
- Configure view features via CollectionViewSource where possible
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SR.Format(SR.MemberNotAllowedForView, "AddNew")
- SR.Format(SR.MemberNotAllowedForView, "CancelNew")
- SR.Format(SR.MemberNotAllowedForView, "CommitNew")
- SR.Format(SR.MemberNotAllowedForView, "EditItem")
- SR.Format(SR.MemberNotAllowedForView, "Remove")
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/358dceaa5be4536b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/ItemCollection.cs:887
if (ecv != null)
{
return ecv.NewItemPlaceholderPosition;
}
else
{
return NewItemPlaceholderPosition.None;
}
}
set
{
IEditableCollectionView ecv = _collectionView as IEditableCollectionView;
if (ecv != null)
{
ecv.NewItemPlaceholderPosition = value;
}
else
{
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, "NewItemPlaceholderPosition"));
}
}
}
/// <summary>
/// Return true if the view supports <seealso cref="IEditableCollectionView.AddNew"/>.
/// </summary>
bool IEditableCollectionView.CanAddNew
{
get
{
IEditableCollectionView ecv = _collectionView as IEditableCollectionView;
if (ecv != null)
{
return ecv.CanAddNew;
}
else
{View on GitHub (pinned to 81131a70a4)