Wednesday, January 4, 2012

In WPF getting error -"specified element is already the logical child of another element. disconnect it first."


→ I have found this error at the time of using datagrid. I have one condition to set visibility of the particular datagrid column.

→ I have used the following ColumnTemplate in the Grid.

  
→ Here, I was using Directly writing Content in the Header , so after set visibility Collapsed to Visible or vice versa for the particular colums, I was getting this error.

→ I have found the solution that , define the Template for the header instead of direct content as below. The Problem has been resolved by this.


1 comment:

  1. Thanks for this solution. Worked like a charm

    ReplyDelete