2
Vote

Element is already the child of another

description

I would like to report two troubles.
 
If I call the next lines:
_aboutView.ShowDialog();
_aboutView.Close();
 
then everything is well. But if I write the next:
_aboutView.Show();
_aboutView.Close();
 
it may cause an error in your source code on the next line:
// If no closing storyboard is defined, close the Popup
this.ChildWindowPopup.IsOpen = false;
 
because ChildWindowPopup is not initialized yet.
 
Now, when I try the next snippet:
_aboutView.Show();
// some little delay
_aboutView.Close();
// some little delay
_aboutView.Show(); // line 3 !
 
sometimes on line 3 get an exception: <Element is already the child of another>
 
it happens, I guess, because this.ParentLayoutRoot.Children still contains a FloatableWindow instance. It removes it only when sb.Completed occurs, but my little_delay sometimes it too little for your animation to be completed in time. So, when the line
 
this.ParentLayoutRoot.Children.Add(this);
 
is called the ParentLayoutRoot still has it.
 

 

Regards

comments