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

Suggested Addition for "How to: Find an Element by Its Name - WPF .NET Framework" #1202

Open
ClockEndGooner opened this issue Oct 31, 2021 · 1 comment
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-framework/svc Pri2 Medium priority wpf/subsvc

Comments

@ClockEndGooner
Copy link

The example's implementation of the Find() method will only find a child element for the specified name that has been added to the Window's or Page's Content as a non-dynamic element. By default, a dynamic UI Element (e.g., the WPF Framework UIElement was instantiated and and added to the Content of the main view programmatically and not through a XAML declaration) is not added as a NameScoped mapped object, and any calls to FindName() using a dynamic object's Name will return a null object reference.

If a FrameworkElement has been added to the Content dynamically, and you would still need to get a reference to the named element, the elements name should be registered to the NameScoped object map by calling the FrameworkElement.RegisterName() method before the element is added to the parent container for a Window or Page's Content.

See Also:

FrameworkElement.RegisterName(String, Object) Method
https://docs.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement.registername?view=windowsdesktop-5.0

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@adegeo
Copy link
Contributor

adegeo commented Nov 2, 2021

Thank you for this information. I'll flag this for updating.

@adegeo adegeo added the doc-enhancement Improve the current content [org][type][category] label Nov 2, 2021
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-framework/svc Pri2 Medium priority wpf/subsvc
Projects
None yet
Development

No branches or pull requests

4 participants