Description
Describe the bug
Hello,
When using a RowDetailsTemplate of a DataGrid, the RowDetailsTemplate will have the parent DataContext set, which causes a crash.
To Reproduce
- Create a list of items
- Assign to a DataGrid
- Launch => the items are displayed.
- Add a RowDetailsTemplate that display some property
- Launch => crash
The issue also happens if there is no item in the list.
(example project included)
Expected behavior
The RowDetailsTemplate DataContext should be the Item and not the parent.
If the list is empty RowDetailsTemplate should not be called since there is no item.
Example Project
In the example project if you launch with the RowDetailsTemplate commented no problem.
But if you uncomment the RowDetailsTemplate you will get a crash because the wrong data context was set:
Unable to cast object of type 'DataGridBug.ViewModels.ItemListViewModel' to type 'DataGridBug.ViewModels.ItemViewModel'.
Even worse if you use the ContentControl instead of the TextBlock it will recursively show the wrong View causing a StackOverFlow.
Informations
- Avalonia Version 11.0.0
Edit: updated post