问题:“指定的元素已经是另一个元素的逻辑子元素.首先断开连接." [英] Issue: "Specified element is already the logical child of another element. Disconnect it first."
问题描述
注意:我已经在6月和7月的CTP位中进行了尝试.
Note: I have tried this with both the June and July CTP bits.
背景:发生此问题,并且在两个XAML窗口之间成功进行了拖放操作.
Background: This issue occurs and the end of a succesful drag and drop operation between two XAML windows.
源是一个包含Button控件的树视图(可以是另一种控件对象,但是我认为这对这个问题无关紧要).将其拖放到第二个xaml窗口中,该窗口是Canvas.
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);
_SelectedElement = (UIElement)e.Source;
this.RemoveLogicalChild(_SelectedElement);
DragDrop.DoDragDrop(_SelectedElement, _SelectedElement, DragDropEffects.All);
-AND-
_SelectedElement =( UIElement )e.Source;
this .RemoveLogicalChild(_SelectedElement);
ContentPresenter oContentPresenter = 新 ContentPresenter ();
oContentPresenter.Content = _SelectedElement;
DragDrop .DoDragDrop(_SelectedElement,_SelectedElement, DragDropEffects .All);
_SelectedElement = (UIElement)e.Source;
this.RemoveLogicalChild(_SelectedElement);
ContentPresenter oContentPresenter = new ContentPresenter();
oContentPresenter.Content = _SelectedElement;
DragDrop.DoDragDrop(_SelectedElement, _SelectedElement, DragDropEffects.All);
此外,我还尝试包装< ControlTemplate > 周围的源"按钮控制没有运气.
Also, I have tried wrapping a <ControlTemplate> around the "Source" Button control with no luck.
欢迎提出任何建议!
谢谢您,
艾伦
Any suggestions are welcome!
Thank you,
Alan
推荐答案
您的问题是否与UI自动化有关?如果不是这样,最好在Windows Presentation Foundation论坛(http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=119&SiteID=1 )
这篇关于问题:“指定的元素已经是另一个元素的逻辑子元素.首先断开连接."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!