In the process of porting my Windows Phone code to Windows 8 (Store App), I came across this interesting problem.
FrameworkElement FieldView = Field.getView( true );
ContentPanel.Children.Add( FieldView );
Panel theParent = VisualTreeHelper.GetParent(FieldView) as Panel;
FrameworkElement theotherparent = (FrameworkElement)FieldView.Parent;
When I call this code in the OnNavigatedTo event handler, the parent elements are null. The FieldView does not show that it has a parent.
A quick post to StackOverflow and I got my answer. Someone suggested that I use the Loaded event handler to then call my code above. This worked. The reason that it worked, I suspect, is that the Grid did not exist as a user interface element when I added the child to it’s Children list. Since there was no Grid in the user interface, there was no user interface parent to set.
This still seems like an API bug to me. the Grid object does exist and the child could still have its parent set to that Grid object.