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

DependencyObjectExtensions.FindLogicalOrVisualAncestor returns null when it should find a parent #1474

Closed
GeertvanHorrik opened this issue Nov 7, 2019 · 7 comments
Assignees
Labels
bug
Milestone

Comments

@GeertvanHorrik
Copy link
Member

@GeertvanHorrik GeertvanHorrik commented Nov 7, 2019

No description provided.

@GeertvanHorrik GeertvanHorrik added the bug label Nov 7, 2019
@GeertvanHorrik GeertvanHorrik self-assigned this Nov 7, 2019
@GeertvanHorrik

This comment has been minimized.

Copy link
Member Author

@GeertvanHorrik GeertvanHorrik commented Nov 7, 2019

Not sure why it only searches 1 level up.

A workaround is using FindLogicalAncestorByType instead.

@GeertvanHorrik GeertvanHorrik added this to the 5.12.0 milestone Nov 7, 2019
@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Nov 7, 2019

Is it getting stuck on one level for all platforms or just a specific one?

GeertvanHorrik added a commit that referenced this issue Nov 7, 2019
…null when it should find a parent
@GeertvanHorrik

This comment has been minimized.

Copy link
Member Author

@GeertvanHorrik GeertvanHorrik commented Nov 7, 2019

It just checks for a single level. Probably for performance reasons, but I wouldn't expect it.

@GeertvanHorrik

This comment has been minimized.

Copy link
Member Author

@GeertvanHorrik GeertvanHorrik commented Nov 7, 2019

Created a fix by defaulting to -1 (check all levels), but still allowing the override of the max depth with new overloads. So the default now checks:

  1. 1 level up (performance mode)
  2. All levels (expensive mode)

You can also call it with maxDepth, then it only searches for maxDepth levels for no 2

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Nov 7, 2019

Strange, we have something similar in our framework called ParentOfType<> (we also have a ChildrenOfType<>) but not with the same quarky behavior.

@GeertvanHorrik

This comment has been minimized.

Copy link
Member Author

@GeertvanHorrik GeertvanHorrik commented Nov 7, 2019

See

var logicalAncestor = FindLogicalAncestor(startElement, condition, 1);
, it capped at 1 level. So now I've added the checks that actually respect the maxDepth that was provided.

@lock

This comment has been minimized.

Copy link

@lock lock bot commented Nov 11, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
1 participant
You can’t perform that action at this time.