PropertyChanged no longer works
mohdimas opened this issue · 1 comments
mohdimas commented
Describe the bug
Calling OnPropertyChanged
to update the UI so it matches the underlying property no longer works.
Xaml:
<CheckBox Content="Bound to IsChecked"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding IsChecked, Mode=OneWay}" />
<TextBlock Text="{Binding IsChecked, StringFormat='Actual IsChecked value: {0}'}" />
<Button Content="Raise property changed"
Command="{Binding RaisePropertyChangedCommand}" />
VM:
private bool _isChecked;
public bool IsChecked
{
get => _isChecked;
set
{
_isChecked = value;
OnPropertyChanged();
}
}
public RelayCommand RaisePropertyChangedCommand { get; }
public MainWindowViewModel()
{
RaisePropertyChangedCommand = new RelayCommand(ExecuteRaisePropertyChanged);
}
private void ExecuteRaisePropertyChanged()
{
OnPropertyChanged(nameof(IsChecked));
}
To Reproduce
- Run the test repository
- Check the checkbox so the UI is checked. But as it's one-way binding, so the underlying property is not updated
- Click the button to call
OnropertyChanged
. - The expected behavior should update the UI to match the underlying property but it doesnt work
Expected behavior
On Avalonia 11.0.13 it still works (TestRepo)
Avalonia version
11.1.0 and above including latest nightly build
OS
macOS
Additional context
No response