-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Remove from logical children and clear item container on reset #15855
Remove from logical children and clear item container on reset #15855
Conversation
…arly like OnItemsChanged.Remove)
You can test this PR using the following package version. |
|
@cla-avalonia agree |
var panel = _presenter.Panel; | ||
|
||
foreach (var c in panel.Children) | ||
{ | ||
itemsControl.RemoveLogicalChild(c); | ||
|
||
if (!c.IsSet(ItemIsOwnContainerProperty)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code was already here, but it looks a bit suspicious. It checks if the ItemIsOwnContainerProperty
is not set, but it should also check if it's set to false
, I think?
EDIT: I see, it's a private property and it's only set to true
, so it's probably done like this for performance reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's just mistake made due to inattention. You can look at the local method Remove in OnItemsChanged at this file. When item removed from the list, it is always remove from logical children and IsOwn property used only for clearing.
A simple test for this case could be added here
|
@pavelovcharov Thanks! I forgot about the test. |
You can test this PR using the following package version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the delay in getting to this, looks good to me, thank you!
What does the pull request do?
On collection reset remove from logical children and clear container (similarly like OnItemsChanged.Remove)
What is the current behavior?
Currently on collection reset removing from logical children happen after checking for ItemIsOwnContainer. And the container is not cleared at all.