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

Unset Parent on Conductors' Items.Clear() #637

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamgauthier
Copy link
Contributor

@adamgauthier adamgauthier commented Sep 24, 2019

ObservableCollection is designed so
NotifyCollectionChangedEventArgs.OldItems is not populated when .Clear()
is called on the collection. Because of this, Caliburn conductors can't
unset the Parent property on all conducted IChild.

There are multiple solutions to this issue that have been discussed, but
I feel like adding a new CollectionCleared event to BindableCollection
is the best compromise considering it doesn't break any existing code
and only extends existing ObservableCollection functionality.

Fixes #465

@adamgauthier
Copy link
Contributor Author

More discussion in #465 and on stackoverflow.

@adamgauthier
Copy link
Contributor Author

Caliburn.Micro.Core.Tests.EventAggregatorSubscribing.Caliburn.Micro.Core.Tests.EventAggregatorSubscribing.A_valid_subscriber_is_assigned_as_a_handler_its_message_type
Assert.True() Failure
Expected: True
Actual:   False

Not sure why that test is failing, everything is green locally. 🤔

ObservableCollection<T> is designed so
NotifyCollectionChangedEventArgs.OldItems is not populated when .Clear()
is called on the collection. Because of this, Caliburn conductors can't
unset the Parent property on all conducted IChild.

There are multiple solutions to this issue that have been discussed, but
I feel like adding a new CollectionCleared event to BindableCollection
is the best compromise considering it doesn't break any existing code
and only extends existing ObservableCollection functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conductor<T>.Collection.OneActive/AllActive - IChild.Parent not reset on clear
1 participant