79673710

Date: 2025-06-20 16:37:48
Score: 0.5
Natty:
Report link
  1. Is this happening on the latest stable Maui 9 version?

  2. Your example could be made a bit more clear with some additional context.
    I've had issues in the past with the UI not updating for CollectionViews because the binding was being set too soon.
    When is LoadDataInternal being called?

  3. Are you adamant on the CommunityToolkit for this? I could not replicate your issue using standard observable properties, but it's also possible this issue is specific to a MAUI version.

If you want to avoid boilerplate you can have a baseviewmodel that inherits from the INotifyPropertyChanged and inherit that

public class BaseViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler? PropertyChanged;
    readonly Dictionary<string, object> _fieldValuesDictionary = new();

    public void OnPropertyChanged([CallerMemberName] string? propertyName = null)
    {
       PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

    public bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
    {
       if (EqualityComparer<T>.Default.Equals(field, value)) return false;
       field = value;
       OnPropertyChanged(propertyName);
       return true;
    }
}

Then your properties will look like this - it's still more code than the CommunityToolkit, but it's neat enough

ObservableCollection<OverallBalance> _monthlyBalances;
public ObservableCollection<OverallBalance> MonthlyBalances
{
    get => _monthlyBalances;
    set => SetField(ref _monthlyBalances, value);
}

OverallBalance _monthlyBalance;
public OverallBalance MonthlyBalance
{
    get => _monthlyBalance;
    set => SetField(ref _monthlyBalance, value);
}
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Is this
  • Low reputation (1):
Posted by: veenx