Datagrid loses its new row placeholder when binded collection is cleared from non-focusable button while user is editing new row.
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: **.NET Core 3.1**
* Windows version: **Win 10 version 1909**
* Does the bug reproduce also in WPF for .NET Framework 4.8?: **Yes**
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)?: **No**
**Problem description:**
When user is editing a new row and clears the collection the datagrid is binded to, datagrid does not get new empty row placeholder. Since datagrid has no editable rows, user can not add new data to it. This only happens when collection.clear() command is binded to a unfocusable button.
**Actual behavior:**
Use attached repo or create new with:
View:
ViewModel:
public class MainVM
{
public ObservableCollection Collection { get; } = new ObservableCollection();
private ICommand _clearCommand;
public ICommand ClearCommand
{
get
{
if (_clearCommand is null)
_clearCommand = new RelayCommand(_ => Collection.Clear(), _ => Collection.Any());
return _clearCommand;
}
}
}
public class A
{
public string Name { get; set; }
public int Age { get; set; }
}
1. Start creating datagridrow:

2. Click the unfocusable button without finishing started new row:

**Expected behavior:**
Datagrid does not lose its new row placeholder and user is able to add new rows.
**Minimal repro:**
https://github.com/kahko/WPFDatagridClearBug
Solution has both .NET Core and .NET Framework projects.
Contributor guide
Assessment
This issue has not been assessed yet.