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

  • SEARCH
  • Home
  • 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 8007949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:59:23+00:00 2026-06-04T17:59:23+00:00

I’m coding a WP7 GUI and have designed a Control class, and a ParentControl

  • 0

I’m coding a WP7 GUI and have designed a Control class, and a ParentControl class that derives from Control and has a list of child controls. However, when adding a child to a ParentControl instance, I’m unable to access the child’s parent reference because I set it to be ‘protected’ from users of the controls.

The exact error is


“Cannot access protected member ‘Control.Parent’ via a qualifier of type ‘Control’;
the qualifier must be of type ‘ParentControl’ (or derived from it)”


    public abstract class Control //such as a button or radio button
    {
        public ParentControl Parent { get; protected set; }
    }


    public abstract class ParentControl : Control //such as a panel or menu
    {
        protected List<Control> children = new List<Control>();;

        public void AddChild(Control child, int index)
        {
            NeedSizeUpdate = true;

            if (child.Parent != null)
                child.Parent.RemoveChild(child);
            child.Parent = this; //How do I access the parent?
            children.Insert(index, child);

            OnChildAdded(index, child);
        }
    }

How might I fix this?

  • 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-06-04T17:59:26+00:00Added an answer on June 4, 2026 at 5:59 pm

    Yes, this is because other things may derive from Control, and ParentControl can only access base members of controls it derives from. For instance, if Control2 derived from Control, then ParentControl would not derive from Control2 and so could not access it’s base members.

    So, you either make Parent a public property, or if you want to keep it hidden away from general users of the control, you could make access via an interface, and implement it explicitly:

    interface IChildControl
    {
        ParentControl Parent { get; set; }
    }
    
    public abstract class Control : IChildControl //such as a button or radio button
    {
        ParentControl IChildControl.Parent { get; set; }
    }
    

    The explicit implementation (IChildControl.Parent) means that consumers with just a Control instance will not see the Parent property. It must be explicitly cast to IChildControl to access it.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.