Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete triggering ModelPropertyChanged for BusinessListBase but not BusinessBindingListBase in Blazor #2954

Open
rockfordlhotka opened this issue May 25, 2022 Discussed in #2951 · 0 comments

Comments

@rockfordlhotka
Copy link
Member

Discussed in #2951

Originally posted by michaelcsikos May 23, 2022
I have two collections, one inherits from BusinessListBase, and the other from BusinessBindingListBase. Each collection is wrapped in a ViewModel<T>. The PropertyChangedEventHandler from the root edit page is passed down to all the children:

// Root edit page
private async void PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
    await InvokeAsync(() => StateHasChanged());
}

// In each child collection
[Parameter]
public PropertyChangedEventHandler PropertyChanged { get; set; }

protected override void OnInitialized()
{
    VM.ModelPropertyChanged += PropertyChanged;
}

In the collection ViewModel, child items are deleted like this:

 public void Remove(WidgetVM context)
 {
     if (Model == null)
         return;

     Model    .Remove(context.Model);
     WidgetVMs.Remove(context);
 }

For the BusinessListBase deleting a child item triggers PropertyChanged, it bubbles up to the root edit page and the Save button becomes enabled, but it's not bubbling up for the BusinessBindingListBase. Ordinarily I would just use BusinessListBase to solve it, but we have some classes which are used in WinForms as well.

Am I approaching this correctly, i.e. making a VM to wrap each collection, and a VM to wrap each child item, and passing PropertyChangedEventHandler down?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant