-
Describe the bug
To ReproduceThis is my project (just started not long ago, to experiment things) Just build and run the project: DumbRenamer.AvaloniaApp.Desktop
Update: For this bug specifically, it is the branch "bug/observable-list". Just build and run the project "AvaloniaBugReport" In file MainWindowViewModel.cs, line 37, method TestNotifiedEnumerableOnCollectionChanged(), you can set breakpoint there, it's the proof that INotifyCollectionChanged is called. Expected behaviorThe ItemsControl displays the items correctly Avalonia version11.0.10 OSWindows Additional contextI need a better ObservableCollection, so I found a third party one, they have their own solutions and I'd like to use it. To my understanding of MVVM, as long as INotifyCollectionChanged is correctly fired, view should be updated. (experience from WPF) (I could use Avalonia ones but I don't want avalonia package involved when design view model. And the Avalonia.Collection namespace is in the Avalonia main package, it's not a independent package.) |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
INCC needs to be on the UI thread. Using their |
Beta Was this translation helpful? Give feedback.
-
I saw it, but I don't need to synchronize across thread (at least not right now), so I thought this is optional. |
Beta Was this translation helpful? Give feedback.
-
Can you please file a minimum sample? I'll not explore a random file renamer as that could be harmful to my machine. |
Beta Was this translation helpful? Give feedback.
-
Hi, this name "DumbRenamer" is a project I just started, despite the solution name, there is not much code, and not much going on, that's why I upload it, and it's without any dll or built binary. But I understand your concern. Here are the some sample code files in a zip (.cs file and .axaml files are not directly allowed somehow) PS: CommunityToolkit.Mvvm package and ObservableCollections package from "https://github.com/Cysharp/ObservableCollections" are required. |
Beta Was this translation helpful? Give feedback.
-
You need the Dispather if you update things from a Task. private async Task ChangeValue()
{
await Task.Delay(1000);
Dispatcher.UiThread.Post(() => { TestInt = 10 });
ExecutePreview();
} |
Beta Was this translation helpful? Give feedback.
-
Hi @timunie and everyone, I created a public repo for bug reporting (I think this probably won't be the last one). https://github.com/cdytoby/AvaloniaBugReport/tree/bug/observable-list For this bug specifically, it is the branch "bug/observable-list". I put the information to the first post too. |
Beta Was this translation helpful? Give feedback.
the docs state this for WPF: https://github.com/Cysharp/ObservableCollections?tab=readme-ov-file#wpf
So you should use another approach, for example DynamicData. It's by design with this lib.