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 8616309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:35:15+00:00 2026-06-12T05:35:15+00:00

I’m writing an app for Windows 8 Metro and am having a problem understanding

  • 0

I’m writing an app for Windows 8 Metro and am having a problem understanding how Canvas’ child-parent relationship works. It seems that when I add one canvas to the children of another, the subcanvas’ ->parent property is equal to null until the parent canvas is added to the visual tree. Below is some sample code showing the problem.

Xaml::Controls::Canvas^ testCanvas = ref new Xaml::Controls::Canvas();
Xaml::Controls::Canvas^ childCanvas = ref new Xaml::Controls::Canvas();
testCanvas->Children->Append(childCanvas);

int size = testCanvas->Children->Size; // size will be equal to 1
if(!childCanvas->Parent)
{
// this code is executed because ->Parent is null. Why is parent here null??
}
aCanvasThatIsPartOfTheVisualTree->Children->Append(testCanvas);
if(!childCanvas->Parent)
{
// this code does not get executed because ->Parent is not null, now that testCanvas is part of the visual tree.
}

I’ve also tried using the VisualTreeHelper to get the parent:

Xaml::Controls::Canvas^ theParent = (Xaml::Controls::Canvas^)VisualTreeHelper::GetParent(childCanvas);

and the behavour remains: theParent is null before testCanvas is added to the visual tree, and not null after testCanvas is added to the visual tree.

If this is not a bug, can someone please tell me how to get a subcanvas’ parent without the parent being part of the visual tree? If it is a bug, are there any known workarounds? Thank you!

  • 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-12T05:35:16+00:00Added an answer on June 12, 2026 at 5:35 am

    If you break apart the name of the VisualTreeHelper you will see that it is the “Visual Tree” helper. That means it is getting the visual parent of the element. If it isn’t currently part of the visual tree then it won’t have a parent as defined by the VisualTreeHelper.

    From here (on VisualTreeHelper.GetParent):

    Returns an object’s parent object in the visual tree.

    From here (on FrameworkElement.Parent from which controls get their Parent property):

    Parent can be null if an object was instantiated, but is not attached to an object
    that eventually connects to a page object root.
    In the default Windows Runtime classes, the parent of a
    FrameworkElement can also be expected to be a FrameworkElement
    subclass if it’s not null. But custom classes might introduce a
    content model where this assumption is not true.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
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’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've tracked down a weird MySQL problem to the two different ways I was

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.