-
-
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
Moving a Control from one parent to another throws an Exception #7381
Comments
The issue only happens when you swap the children of two parents and one of them has no children. Here is an updated test code:
(Also, same behavior for Border.Child, if one of the parents has no child, it will throw...) |
Following my last comment, a temporary workaround is to simply check if the parent has no children/child and assign to it an empty control before assigning the swapped child. (And maybe delete it later depending on your logic...) Like this:
|
When a control was move from one parent container to another, and that move caused the new parent container to be laid out in a different position, a code path was taken which resulted in the `VisualNode` being present under both the old and new containers. Ensure that the node is removed from its old parent in this case. Fixes #7381 Fixes #6103 (probably)
Describe the bug
If you have one control, you move it from parent1 to parent2, a NullReferenceException is thrown:
Exception details
To Reproduce
And
Expected behavior
TextBlock should be removed from the old parent and added to the new parent.
Desktop (please complete the following information):
Additional context
It doesn't work with other types of parents as well (e.g. Border).
Also, the Exception is thrown here:
Simply adding a null check at
operation.Item?.Render(context);
will cause other Exceptions:Exception details
The text was updated successfully, but these errors were encountered: