Describe the bug
When I bind an entry of an observable dictionary using "{Binding Dictionary[Key]}", it does not detect changes.
To Reproduce
- Create a new Avalonia MVVM app.
- Add a view model property with an
AvaloniaDictionary (or other observable dictionary).
public partial class MainWindowViewModel : ViewModelBase
{
...
public AvaloniaDictionary<string, string> Dictionary { get; } = new();
...
}
- Bind a dictionary entry in the view.
<Window ...>
...
<TextBlock Text="{Binding Dictionary[MyKey]}" />
...
</Window>
- Now programmatically change the value of
Dictionary["MyKey"].
Result: The UI does not detect the change. The TextBlock.Text is not updated.
Expected behavior
The AvaloniaDictionary implements INotifyPropertyChanged and INotifyCollectionChanged, therefore I expect the UI to detect changes and update the UI text.
Avalonia version
11.3.10
OS
Windows
Additional context
It works when the observable dictionary raises a PropertyChanged event with new PropertyChangedEventArgs("Item"). It does not work with new PropertyChangedEventArgs("Item[]").
Note that binding an ObservableCollection with {Binding List[0]}" is working fine. It is only a problem with dictionaries.
Describe the bug
When I bind an entry of an observable dictionary using
"{Binding Dictionary[Key]}", it does not detect changes.To Reproduce
AvaloniaDictionary(or other observable dictionary).Dictionary["MyKey"].Result: The UI does not detect the change. The
TextBlock.Textis not updated.Expected behavior
The
AvaloniaDictionaryimplementsINotifyPropertyChangedandINotifyCollectionChanged, therefore I expect the UI to detect changes and update the UI text.Avalonia version
11.3.10
OS
Windows
Additional context
It works when the observable dictionary raises a
PropertyChangedevent withnew PropertyChangedEventArgs("Item"). It does not work withnew PropertyChangedEventArgs("Item[]").Note that binding an
ObservableCollectionwith{Binding List[0]}"is working fine. It is only a problem with dictionaries.