Specified element is already the logical child of another element. Disconnect it first.(DataGrid) - by CSSForumEngineer

Status : 

  External<br /><br />
		This item may be valid but belongs to an external system out of the direct control of this product team.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


4
0
Sign in
to vote
ID 780079 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/26/2013 9:39:39 PM
Access Restriction Public

Description

OS info:

  OS:64-bit Operating System
  Processor:i7-2600
  Edition: Windows 7 Enterprise SP1
VS info:

Visual Studio 2010 Premium/Ultimate
Version 10.0.40219.1 SP1Rel

I met a problem when I build one WPF Application.

1) Make sure the current windows theme is "Windows 7 Basic"

2) Create one WPF Application and pasted below code in the xaml window.

      <Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <DataGrid>
            <DataGrid.Columns>
                <DataGridTextColumn >
                    <DataGridTextColumn.Header>
                        <Border HorizontalAlignment="Center" VerticalAlignment="Center" >
                            <TextBlock Text="aaa"/>
                        </Border>
                    </DataGridTextColumn.Header>
                </DataGridTextColumn>
                <DataGridTextColumn Header="Test1"/>
                <DataGridTextColumn Header="Test1"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>
3) Build and run this application.

4) Switch the windows theme to "Windows Classic"

5) The WPF application crashed.

I got below error information,

System.InvalidOperationException
Specified element is already the logical child of another element. Disconnect it first.
   at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
   at System.Windows.FrameworkElement.AddLogicalChild(Object child)
   at System.Windows.Controls.ContentControl.OnContentChanged(Object oldContent, Object newContent)
   ...

By the way, I tested in the other windows themes, the results as below

"Windows 7 Basic"-> "Windows Classic" --- Crashed
"Windows 7 Basic"->" High Contrast #1" --- Crashed
"Windows 7 Basic"-> "High Contrast Black"--- Crashed
"Windows Classic" -> "Windows 7 Basic"--- Crashed
"Windows Classic"-> "High Contrast Black"--- No Crash
"High Contrast Black"-> "Windows 7 Basic"--- Crashed
"High Contrast Black"-> "Windows Classic"--- No Crash
"High Contrast Black"-> "High Contrast #1"--- No Crash
Sign in to post a comment.
Posted by Microsoft on 2/27/2013 at 1:35 AM
Thanks for your feedback . The product team itself no longer directly accepting feedback for Microsoft Visual Studio 2010 and earlier products. You can get support for issues with Visual Studio 2010 and earlier by visiting one of the resources in the link below:
<http://msdn.microsoft.com/en-us/vstudio/cc136615.aspx>
Posted by Helen [MSFT] on 2/26/2013 at 9:50 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)