Cannot find child name in Grid.
Posted: 02 Dec 2018, 02:02
I'm currently working on a navigation system. When a view is told be be shown, the navigation first looks if a control of that name already exists. If not, it creates the element, gives it a name, and adds it to the children of the root. If it does exist, it will simply enable and show that instead of creating a new one.
The problem is that I cannot find any children I've added.
I cannot seem to find an object of that name. If I create the view in XAML and give it an x:Name attribute, FindName does work. Furthermore, when I look up all children, it says the source is null.
https://i.imgur.com/K7zTRjp.png
The problem is that I cannot find any children I've added.
Code: Select all
control.Name = "Name";
Root.Children.Add(control);
Root.FindName("Name");
Code: Select all
IEnumerable<object> c = Root.Children.OfType<object>();