Issue: "Specified element is already the logical child of another element. Disconnect it fi

Note: I have tried this with both the June and July CTP bits.

Background: This issue occurs and the end of a succesful drag and drop operation between two XAML windows.

The source is a treeview that contains a Button control (could be another kind of control object, but I don't think it matters for this issue). That is drag and dropped unto a 2nd xaml window which is a Canvas.

I have tried the following code fragments:

_SelectedElement = (UIElement)e.Source;
this.RemoveLogicalChild(_SelectedElement);
DragDrop.DoDragDrop(_SelectedElement, _SelectedElement,DragDropEffects.All);

-AND-

_SelectedElement = (UIElement)e.Source;
this.RemoveLogicalChild(_SelectedElement);
ContentPresenter oContentPresenter =newContentPresenter();
oContentPresenter.Content = _SelectedElement;
DragDrop.DoDragDrop(_SelectedElement, _SelectedElement,DragDropEffects.All);

Also, I have tried wrapping a<ControlTemplate> around the "Source" Button control with no luck.

Any suggestions are welcome!
Thank you,
Alan

[1971 byte] By [AlanPainter] at [2008-2-7]
# 1

Is your question related to UI Automation in any way? If not, it might be best asked in the Windows Presentation Foundation forum (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=119&SiteID=1).

PeterDonnelly-MSFT at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Microsoft UI Automation...
# 2
Rather than using this.RemoveLogicalChild try using the parent element of the selected element.
MichaelLatta at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Microsoft UI Automation...

Software Development for Windows Vista

Site Classified