dotnet/wpf · error · InvalidOperationException
throw new…
Error message
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, "EditItem"));
What it means
CollectionViewProxy.EditItem(item) starts an edit transaction on the proxied view via IEditableCollectionView. When the wrapped view does not implement that interface (null `ecv` at CollectionViewProxy.cs:603), the proxy throws InvalidOperationException: editing is not allowed for this view.
Solutions
- Check CanEditItem (or cast ProxiedView as IEditableCollectionView) before calling EditItem
- Edit the data object directly and raise PropertyChanged instead of using view-level edit transactions
- Use a source collection whose view implements IEditableCollectionView
Example fix
// before
proxy.EditItem(currentItem);
// after
if (proxy.CanEditItem)
{
proxy.EditItem(currentItem);
} Defensive patterns
Strategy: validation
Validate before calling
if (!proxy.CanEditItem) return; proxy.EditItem(item);
Type guard
bool SupportsEditItem(CollectionViewProxy p) => p?.ProxiedView is IEditableCollectionView;
Try / catch
try { proxy.EditItem(item); }
catch (InvalidOperationException ex) when (ex.Message.Contains("EditItem")) { /* edit object directly instead */ } Prevention
- Check CanEditItem before starting edit transactions
- Edit the business object and raise PropertyChanged as a fallback
- Only use view-level editing with collections whose views implement IEditableCollectionView
When it happens
Trigger: Calling EditItem on a CollectionViewProxy whose ProxiedView is not an IEditableCollectionView (e.g. custom views, views over non-editable sources).
Common situations: Programmatic cell-edit commits in data grids bound to unsupported collections; data-binding infrastructure invoking EditItem automatically; view code ported between collection types.
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
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/fbb0d89a722a18e8.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/CollectionViewProxy.cs:603
#region Transactional editing of an item
/// <summary>
/// Begins an editing transaction on the given item. The transaction is
/// completed by calling either <seealso cref="IEditableCollectionView.CommitEdit"/> or
/// <seealso cref="IEditableCollectionView.CancelEdit"/>. Any changes made to the item during
/// the transaction are considered "pending", provided that the view supports
/// the notion of "pending changes" for the given item.
/// </summary>
void IEditableCollectionView.EditItem(object item)
{
IEditableCollectionView ecv = ProxiedView as IEditableCollectionView;
if (ecv != null)
{
ecv.EditItem(item);
}
else
{
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, "EditItem"));
}
}
/// <summary>
/// Complete the transaction started by <seealso cref="IEditableCollectionView.EditItem"/>.
/// The pending changes (if any) to the item are committed.
/// </summary>
void IEditableCollectionView.CommitEdit()
{
IEditableCollectionView ecv = ProxiedView as IEditableCollectionView;
if (ecv != null)
{
ecv.CommitEdit();
}
else
{
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, "CommitEdit"));
}View on GitHub (pinned to 81131a70a4)