dotnet / dotnet/wpf

DataTable Binding – Header containing "/" symbol prevents cell rendering in WPF DataGrid

Open
#11,066 4 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

Environment:
- OS: Windows 11 (64-bit)
- .NET version: .NET 9

When binding a System.Data.DataTable to a WPF DataGrid, if the DataColumn.ColumnName contains a / (forward slash), all subsequent cells in that column fail to display values.

This behavior occurs consistently and is independent of the data type or number of rows.

Demo project:
[DataGridTableBug.zip](https://github.com/user-attachments/files/21918537/DataGridTableBug.zip)

### Reproduction Steps

```
public static DataTable LoadDataTable()
{
DataTable table = new DataTable();

table.Columns.Add("2025-Forecast");
table.Columns.Add("2025/Forecast"); // header with '/'

for (int i = 0; i < 7; i++)
{
var dataRow = table.NewRow();
dataRow[0] = $"Value1 {i}";
dataRow[1] = $"Value2 {i}";
table.Rows.Add(dataRow);
}

foreach (var c in table.Columns)
{
Debug.WriteLine(c.ToString());
}
return table;
}
```

![Image](https://github.com/user-attachments/assets/a262fc56-1178-42e1-9510-61d57444887d)

### Expected behavior

Display all values

### Actual behavior

Empty cells under the header with a "/" symbol.

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### 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.