I have a series of controls that can be passed around and on occasion they are added as a child to another control.
In many cases I cannot know for certain if the control is currently the child of another control.
For example :
Label lbl = new Label( );
/*Stuff happens; lbl may be assigned or not; whatever.*/
//If the label has already been assigned as a child to a viewbox
if ( lbl.Parent is Viewbox )
return lbl.Parent;
else {
if (lbl.Parent != null )
//Of course this fails because there is no lbl.Parent.Child property.
lbl.Parent.Child = null;
return new Viewbox( ) { Child = lbl, Stretch = Stretch.Uniform };
}
It is entirely possible I am completely misinterpreting the function of the Control.Parent property.
Is it possible to orphan a control from it's parent through the control itself?