dotnet / dotnet/wpf

Crash when attempting to edit item in default DataGrid

Open
#9,131 8 comments 0 reactions 0 assignees View on GitHub
Investigate needs more information
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

When double-clicking a cell inside a GridView to edit it, the program crashes with an unhandled exception.

```
PresentationFramework.dll!System.Windows.Controls.ItemCollection.System.ComponentModel.IEditableCollectionView.EditItem(object item) Line 1668
```

### Reproduction Steps

1. Create a DataGrid
2. Create a basic PODO
3. Define columns for the PODO properties in the DataGrid
4. Add a PODO instance to the DataGrid's Items collection

```xml




```

```cs
public MainWindow()
{
InitializeComponent();
dataGrid.Items.Add(new Something()
{
A = "Hello",
B = "World",
});
}

public class Something
{
public string A { get; set; }
public string B { get; set; }
}
```

### Expected behavior

The interaction doesn't cause an unhandled exception.

### Actual behavior

The interaction causes an unhandled exception, even in Release mode.

```
PresentationFramework.dll!System.Windows.Controls.ItemCollection.System.ComponentModel.IEditableCollectionView.EditItem(object item) Line 1668
```

### Regression?

_No response_

### Known Workarounds

Specifying `IsReadOnly="True"`

### Impact

While possibly intended, it is still unexpected to have the default behaviour of a DataGrid bound to a non `IEditableCollectionView`-implementing PODO consist of a plain crash.

### Configuration

- .NET 8.0
- Win11 23H2
- x86

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.