I am trying to insert several rectangles on the stack, but I keep getting an error. An element is already a child of another element. The same thing happens if I use canvas.
Example:
List<Rectangle> recList = new List<Rectangle>();
... put some rectangles on the list
StackPanel stack = new StackPanel();
foreach(var item in recList)
stack.Children.Add(item);
uiStackPanel.Children.Add(stack);
I want to be able to dynamically insert rectangles in horizontal orientation. According to the internet, I should be able to do this (at least manually), but ...
What to do, what to do? :)
source
share