0

How can I reparent an UIElement to another Window? I have set Content to null prior to closing the Window. Afterwards a new Window is started and the UIElement is set to the Content of that Window.

This gives an InvalidOperationException: "Het opgegeven element is al het logische onderliggende element van een ander element. Koppel dit eerst los."

Unfortunately my windows is dutch. The rough translation is as follows: "The specified element is already the logical child element of another element. Disconnect it first."

The thing I don't understand is that I have decoupled it, but still it gives this error.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Wouter
  • 2,170
  • 1
  • 28
  • 58

1 Answers1

1

Just making the content null will not effect the parent child relation ship. You need to use RemoveLogicalChild function of window to remove the UIElement as child of the previous window and then attach it to new window.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Fatema
  • 135
  • 1
  • 10
  • I get the same error when using RemoveLogicalChild. In conjunction with RemoveVisualChild I still get the same error.. – Wouter Nov 03 '10 at 11:20
  • Can you provide with a code sample as RemoveLogicalChild fuction works great for me. – Fatema Nov 04 '10 at 05:40