-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Suggestion to change default method behavior for .Children (and add it to all elements) #948
Comments
Not sure what exactly is asked here. (a) Having a Besides, there are multiple trees (at least visual and logical, some controls have additional ones) - exposing one of them as property on all controls will pose the question which to expose. The existing (b) Recursively traversing children down the tree is an antipattern in WPF, it should not be encouraged by the framework
The correct way to locate child elements is using their names. If you have XAML code behind you can access elements directly by name already, if you are using templates there are existing functions to find named elements, and there are existing contracts (TemplatePartAttribute) which named elements calling code can expect in a template. Any elements beyond that contract are not guaranteed to be part of the style, though if you just defined the name in your own style then you can of course rely on it being present. |
I'm reluctant to go down the path of considering If there is a specific and scoped addition to There are always going to be individual use-cases that fail to be addressing directly by existing We'd want to be persuaded that a common use-case is being addressed as part of any proposal for additions to /cc @matu3ba (who opened the original issue on Microsoft/WPF-Samples) |
This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions! |
Copying from WPF Samples Repo: microsoft/WPF-Samples#77
Dear Devs,
it is kind of a pain to iterate through the whole page xaml for finding certain items.
The default methods .Content and .Children differ on the tree which is annoying (for beginners).
Could you improve the default method like using default examples for VisualTreeHelper?
Further it is annoying being forced to cast the method
(having not the same container providing .Children method) for the IntelliCode support.
Using multiple or deep Pages could be written recursively or iteratively much faster when the type is fixed providing and the same method could be used.
This
https://stackoverflow.com/questions/636383/how-can-i-find-wpf-controls-by-name-or-type/1759923#1759923
and this
https://codereview.stackexchange.com/questions/44760/is-there-a-better-way-to-get-a-child
relates to that.
The text was updated successfully, but these errors were encountered: