This project is read-only.

InvalidOperationException occurs when the same view instance is added to multiple ContentControl regions


When the same view instance is added to more than one ContentControl region, an unhandled InvalidOperationException occurs.

Repro Steps

  1. Define two ContentControl regions Region A and Region B.
  2. Add view1 to both the Regions A and B.
  3. Display Region A's view using Region A.Show(view1) method.
  4. Display Region B's view using Region B.Show(view1) method.
  5. Unhandled Exception is thrown. - "Specified element is already the logical child of another element. Disconnect it first."

Offending Code

File Name: SimpleRegion.cs
Line Nº: 119
public void Show(object view)
    if (!Views.Contains(view))


Before associating a view with the parent element, a conditional check can be made to find if the view is already associated with some other parent element.

Last edited Jun 25, 2008 at 4:12 PM by mconverti, version 1


No comments yet.