-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataGrid does not refresh if source updated outside view #9527
Comments
After switching the tab, DataGrid even won't listen to PropertyChanged events anymore. I tried to invoke property changed event for ItemsSource property in viewmodel while activating but it doesn't affect. this.WhenActivated(delegate (CompositeDisposable _)
{
// I expected it re-draws rows here but nothing happens.
this.RaisePropertyChanged(nameof(Items));
}); |
This is caused by this code in the DataGrid: Avalonia/src/Avalonia.Controls.DataGrid/DataGrid.cs Lines 2110 to 2118 in 7580b70
Simply not unwiring events seems to work but I don't know what the resolution should be while keeping the intended behaviour. Looking at the commit bbf3099 indicates the problem was a ViewModel/Collection keeping the DataGrid from being garbage collected, but that strikes me as an intended thing, if the ViewModel isn't being released then why would you expect the view for it to be released. On second thought perhaps simply calling |
Any update on this? |
@enisn the issue has the help wanted label. So if you or anyone else want to file a PR to solve the issue, feel free to do. Also testing latest master again could be useful. |
I just faced this issue, here is my temporary solution: switch to the tab that shows the DataGrid, update its ItemsSource, then switch back to the tab that was visible before. This makes the DataGrid view to be updated. |
any update? |
this solve my issue, just use a index bindind
|
I just tested this on master and I can't seem to reproduce it so I'm inclined to say it's fixed. Has anyone tried rc-1.1? |
nothing changed at all, try the below demo |
Describe the bug
In Avalonia 0.11.0-Preview4 when updating (add or delete) the Items of a DataGrid when the view is not displayed (in another TabItem for example) the DataGrid doesn't get refreshed.
The issue doesn't happen in 0.18.0
To Reproduce
Steps to reproduce the behavior:
Add Item
ButtonClear
ButtonSame issue when clicking
Add Items
in the "B" Tab, the added Items are not displayed in the DataGrid.Expected behavior
The removed items should not be shown.
Desktop:
The text was updated successfully, but these errors were encountered: