This is a migrated thread and some comments may be shown as answers.

Error with ContextMenu 'element is already the child of another element'

2 Answers 95 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 19 Nov 2010, 07:59 PM
Hi,

I have a user control that I have developed using the RadRichTextBox.  When I enable the context menu on the RichTextBox, I get Application Error 4009: "element is already the child of another element".  I have extracted my user control into an external project to see if I can reproduce the problem outside of my application, but it seems to work when it is outside my application.

I know that the ContextMenu must be set using an attached property inside the RadRichTextBox, so I think it must be getting confused somehow based on the way that it is used in the logical tree of my application.  Is this a known issue?  How can I go about tracking down what could possibly be wrong with the XAML in my application?

Thanks,

Rob

2 Answers, 1 is accepted

Sort by
0
Rob
Top achievements
Rank 1
answered on 19 Nov 2010, 08:16 PM
I just eliminated one of the error windows by including the "inserthyperlink.png" context menu icon in my global resource dictionary.  I have also had problems loading Icons into the ContextMenuItems, how are these related?  I think that some of the images on the contextmenu are actually being reused on the buttons on my user control.  Is this causing a conflict somehow?

<Image x:Key="hyperlink" Source="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/inserthyperlink.png"/>
0
Boby
Telerik team
answered on 22 Nov 2010, 03:12 PM
Hi Rob,
We did not manage to reproduce your problem, However, 'Element is already the child of another element' error message can mean you are incorrectly reusing your resources across your application (you can check the following article).
Actually, MEF is responsible for loading an instance of context menu in the RadRichTextBox.ContextMenu property, so you don't have to set it manually.

Any other details or sample project (if you manage to reproduce the problem) would be highly appreciated, so we can investigate the problem further.

Best wishes,
Boby
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
RichTextBox
Asked by
Rob
Top achievements
Rank 1
Answers by
Rob
Top achievements
Rank 1
Boby
Telerik team
Share this question
or