Skip to content

Notify related Property without call setter #1109

Description

@ahdung

some times we need notify Property changed manually, for example, notify Total when collection changed, in this case we do not call Total=xxx, just call OnPropertyChanged("Total"), this cause other property that reference Total can't raised, so can you don't generate this:

public string GivenNames
{
public string GivenNames
{
  get => givenNames;
  set
  {
    if (value != givenNames)
    {
      givenNames = value;
      OnPropertyChanged(InternalEventArgsCache.GivenNames);
      OnPropertyChanged(InternalEventArgsCache.FullName);
    }
  }
}

generate this:

public string GivenNames
{
  get => givenNames;
  set
  {
    if (value != givenNames)
    {
      givenNames = value;
      OnPropertyChanged(InternalEventArgsCache.GivenNames);
    }
  }
}

void OnPropertyChanged(PropertyChangedEventArgs eventArgs)
{
  PropertyChanged?.Invoke(this, eventArgs);

  if (eventArgs == InternalEventArgsCache.GivenNames)
    PropertyChanged?.Invoke(this, InternalEventArgsCache.FullName);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions