Skip to content
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

PropertyChanged from model not handled properly #292

Open
blackmole opened this issue Jun 2, 2024 · 1 comment
Open

PropertyChanged from model not handled properly #292

blackmole opened this issue Jun 2, 2024 · 1 comment

Comments

@blackmole
Copy link

Hi there,
I observed an issue when updating properties in the model. I hope it's not a mishandling from my side, but I think it's a bug.

Setup:
I've got a model which has a property Size, which for Folders is the sum of all children sizes. I have a TreeDataGrid that has a column showing the size, AutoDragDrop enabled, with Items only being allowed to be dropped on Folders. The TreeDataGrid also shows another int column. Each time the ObservableCollection containing the children fires a CollectionChanged, a RaisePropertyChanged(nameof(Size)) is called.

Action:
I move items around.

Expected behavior:
The value in the Size column changed every time I move an item around.

Observed behavior:
The value in the Size column changes every second time. (Depending on the number of int columns less often).
In the following gif you can observe the behavior. Left hand side is the described behavior, right hand side as I would expect it. Only difference is the int column.
Avalonia_TreeDataGrid_ValueUpdate

I tried to use a string text column with x => x.Prop.ToString(), but I get an exception: System.ArgumentException Expression of type 'System.Int32' cannot be used for return type 'System.Object'

Here's the code: https://github.com/blackmole/AvaloniaTreeDataGridValueUpdate

@blackmole
Copy link
Author

This issues apparently not only appears when there are two int columns, but also for two string columns. Not sure what the exact condition is though, but when I have a table with only two strings and update the second one, it only works every second time.

My workaround: Fire the PropertyChanged event twice. Ugly, but working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant