Reputation: 2613
I'm adding rectangles to a wrap panel like this:
For i = 0 to 20
wrapPanel.children.add()
next
I would like to use this loop because I don't want to specify the limit:
Do
wrapPanel.children.add()
Loop
But how can I break the loop when the wrap panel is filled? For example the loop would stop when the wrap panel can't display a rectangle in its full height or width.
Upvotes: 0
Views: 1250
Reputation: 21
this is giving error "Specified Visual is already a child of another Visual or the root of a CompositionTarget." I want to read data from xml file using user control.
List<careeroption> qz = new List<careeroption>();
qz = KompkinDP.GetQuizList(CareerID.ToString());
foreach (careeroption q in qz)
{
UserControl1 uc = new UserControl1();
for (int i = 0; i < q.CareerOptionQuiz.Count; i++)
{
uc.QuizName = q.CareerOptionQuiz[i];
wrap1.Children.Add(uc);
}
// wrap1.Children.Add(uc);
}
Upvotes: 2
Reputation: 2613
I finally got it working! I'm using Canvas instead of Wrap Panel. Here's the working code:
for y = 0 to Canvas.height - Rectangle.height Step Rectangle.height
for x = 0 to Canvas.width - Rectangle.width Step Rectangle.width
Canvas.sety(Rectangle,y)
Canvas.setx(Rectangle,x)
Canvas.children.add(Rectangle)
next
next
Upvotes: 1