I have an application that loads a XAML file, and shows it in a ContentControl. What I also want to implement is a way to go over the XAML code that was loaded to the control and populate a listbox with the names of the Canvases I find.
The main task of this tiny application is to enable the user to change colors of specific canvases and their elements. Meaning that I have, for example 10 canvases, each containing some <Path> elements. I want to give the user a list of the canvases that were found in the XAML code, and for each canvas the user will be able to change its fill color (for example), if the user changes the fill color of a specific canvas, the child elements of that canvas will change their “Fill” attribute to the selected color as well.
I didn’t find a way to iterate through the Canvases or the Path elements, so if anyone have a way to do this I would be glad to hear.
Thanks!
You seem to need to traverse the logical children tree of a given control. For this, you need to use
LogicalChildrenproperty recursively.You can find more information on the element trees in WPF here.