Closed sinatrocious closed 1 year ago
Will the issue get fixed with #12009?
@sinatrocious good question. The PR you mentioned is merged. this means, you can test with using nightly builds. You can close this issue if fixed in nightly builds.
https://github.com/AvaloniaUI/Avalonia/wiki/Using-nightly-build-feed
@timunie , I've updated avalonia to 11.0.1, the issue is fixed.
Describe the bug If
DataGrid
is removed from visual tree then it will ignore changes done to collection bound to itsItemsSource
. This happens, to example, when DataGrid is located inside an inactiveTabItem
or not yet openedPopup
.To Reproduce Here is repro: AvaloniaApplication1.zip
Or simply make a new Avalonia project and modify
MainWindow
:Axaml:
ViewModel:
App.xaml:
Here is a
TabControl
with 2 tabs: one withDataGrid
and empty one. A button on the right displayes items count.Switching to another tab and pressing button to add items will lead to the state, where
DataGrid
is desynchronized and displays wrong content, which does not correspond to the actual.Expected behavior The
DataGrid
should show correct and actual content, disregards if items are added while it's not visible.Screenshots
Gif:
Desktop (please complete the following information):
Additional context
The issue arises when we start using Avalonia 11.0.0. Everything was ok in 0.10.19.
There are several workarounds, so it's not urgent to fix:
DataGrid
a part of visual tree first, e.g. by first showingPopup
and then adding items;DataGrid.ItemsSource
by setting it tonull
and then back...The
ListBox
doesn't have this issue.The issue occurs with
AvaloniaList
andObservableCollection<T>
.Deleting items and resetting collection also pose a problem.