How do you access the children of a WPF Canvas class?

12,944

You can use the Children property.


Edit: Here is an example of iterating over the children and getting one by index:

foreach (UIElement child in canvas.Children)
{
    // ...
}
// Or: 
int index = 0;
var childByIndex = canvas.Children[index];
Share:
12,944
xarzu
Author by

xarzu

Why Would I Use My Real Name When "Xarzu" Is so Cool? (I am not really 90 years old either) http://s3.envato.com/files/190523.jpg

Updated on July 16, 2022

Comments

  • xarzu
    xarzu almost 2 years

    How do you access the children of a WPF Canvas class?

    It is a cool class and I like how you are able to add children. But once they are there, how to you look at them for reading their state and content. I know it is easy if you put the children in XAML. But what if you have added children to the canvas dynamically at run time?