Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7667311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:04:14+00:00 2026-05-31T15:04:14+00:00

I have a question: I keep getting an InvalidOperationException: Element is already child of

  • 0

I have a question: I keep getting an InvalidOperationException: Element is already child of another element thrown in WP7. This occurs when you try to add a UIElement more then once to any display element. This would make sence, because I add multiple static members to a paragraph in a rich text box, so if I were to add the static members again, to any displayElement, I would get this exception. But in the OnNavigatingFrom method, I Clear the entire list of items in the paragraph, so they should not be in the list anymore, and the exception should not show. Other, non-static members do not show this exception. Anyone has any suggestions?

private static Hyperlink websiteHyperLink   = new Hyperlink( );
method:
if ( NavigationContext.QueryString.TryGetValue( key, out value ) )
        {
            Bold bold = new Bold( );

            bold.Inlines.Add( UsedLanguage.cv_page_website );
            websiteHyperLink.Inlines.Add( website );
            websiteHyperLink.TargetName = website;
            websiteHyperLink.Click += new RoutedEventHandler( OpenBrowserClient );

            mParagraph.Inlines.Add( bold );
            mParagraph.Inlines.Add( websiteHyperLink );
            mParagraph.Inlines.Add( "\n" );
        }
 protected override void OnBackKeyPress ( System.ComponentModel.CancelEventArgs e )
        {
            mParagraphs.Inlines.Clear( );
            base.OnBackKeyPress ( e );
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:04:15+00:00Added an answer on May 31, 2026 at 3:04 pm

    Don’t do this on OnBackKeyPress – this will not handle all cases.

    Run your clear code in the OnNavigatedFrom() [which is what your text is saying, but not your code] override, when the NavigationMode (inside the event args) is set to “Back”.

    Also, note that OnNavigateTo() can be called multiple times on the same instance (for example, when you navigate back into it) – have a local variable that says whether or not you already added the items so you don’t hit it again.

    Clarification questions: Do you load the same page multiple times, or do you load it only once?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello all im back with another question on my project. i keep getting stuck
I have question regarding the SQLAlchemy. How can I add into my mapped class
I have question regarding disabling browser caching. I have already found few solutions, and
PLEASE NOTE: This is a CODE QUESTION NOT AN SYSTEM MANIPULATION ONE. I have
In a previous question: Getting "This method or property cannot be called on Null
following on from this question . I have the following: models.py VARIABLE_CHOICES = (
All, I have a guestbook feature on my site and I keep getting spammed.
i have a pretty basic jquery question. im trying to add jscrollpane to my
Similar to this question I have a small groovy test script that basically uses
I keep getting an error when overriding my getview method. This is what I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.