dotnet / dotnet/wpf

DataGrid Cancel Edit Crashes with a template column binding to Run.Text

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

Description

### Description

In a data grid setup with
```






```

This crashes when I edit the text column and then cancel it with ESC.

The Exception is thrown in `VisualTreeUtils.EnsureVisual`, with text `'{0}' is not a Visual or Visual3D.`

### Reproduction Steps

Create a WPF application for .NET Framework 4.8
Put a Datagrid on the window, and add the template column shown above

### Expected behavior

Does not throw an exception

### Actual behavior

Throws an exception

### Regression?

_No response_

### Known Workarounds

If you add to the binding a `Mode=OneWay` specification, the crash does not occur

### Impact

Need to find the workaround and apply it in code, adding unnecessary complexity.

### Configuration

Windows 10, fully updated February 2023, .NET Framework 4.8.1

### Other information

When restoring information, the code seems to go through the bindings, and assumes that all are bound to a Visual. But a `Run` is not a visual.

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.