With data-binding, you need to implement the
PropertyChangedEventHandler
to notify the data-binding which property has changed.
Here is a base class implementation:
public abstract class ObservableObject : INotifyPropertyChanged
{
protected bool Set<TValue>(
ref TValue field,
TValue newValue,
[CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<TValue>.Default.Equals(field, newValue))
return false;
field = newValue;
OnPropertyChanged(propertyName);
return true;
}
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged(
[CallerMemberName] string? propertyName = null)
=> PropertyChanged?.Invoke(
this,
new PropertyChangedEventArgs(propertyName));
}
And to use, inherit the
ObservableObject
to you
ViewModel
, then change your property as follows:
private bool _isCheckAll
public bool IsCheckAll
{
get => _isCheckAll;
set => Set(ref _isCheckAll, value);
}
Also, you don't implement the
UpdateSourceTrigger
like that.
Please take the time to do this tutorial:
MVVM Tutorial[
^] or this:
Model-View-ViewModel | Microsoft Learn[
^]