Skip to content

ChildChanged Event not being triggered in the Blazor ViewModel for BusinessListBase objects #4723

@mtavares628

Description

@mtavares628

Describe the bug
The ChildChanged event on the Blazor ViewModel is not getting triggered when the Model object is of type BusinessListBase. It looks like it only triggers for IBusinessBase objects.

Version and Platform
CSLA version: 9.1.0
OS: Windows
Platform: Blazor Server

Code that Fails

/// <summary>
    /// Unhooks changed event handlers from the model.
    /// </summary>
    /// <param name="model"></param>
    protected void UnhookChangedEvents(T? model)
    {
      if (model is INotifyPropertyChanged npc)
        npc.PropertyChanged -= OnModelPropertyChanged;

      if (model is IBusinessBase ncc)
        ncc.ChildChanged -= OnModelChildChanged;

      if (model is INotifyCollectionChanged cc)
        cc.CollectionChanged -= OnModelCollectionChanged;
    }

    /// <summary>
    /// Hooks changed events on the model.
    /// </summary>
    /// <param name="model"></param>
    private void HookChangedEvents(T? model)
    {
      if (model is INotifyPropertyChanged npc)
        npc.PropertyChanged += OnModelPropertyChanged;

      if (model is IBusinessBase ncc)
        ncc.ChildChanged += OnModelChildChanged;

      if (model is INotifyCollectionChanged cc)
        cc.CollectionChanged += OnModelCollectionChanged;
    }

Additional context
I think changing the above code to check for INotifyChildChanged instead of IBusinessBase would solve this issue.

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions