The problem seems to be as obvious as your formulation. You mention "just one row" and immediately one would try to see where you shift the rectangle for a row. And it becomes obvious, because you use
Canvas.SetLeft
, but never
Canvas.SetTop
. Apparently, for every row you should use different top coordinate. Add the call to
Canvas.SetTop
:
Canvas.SetTop Method (System.Windows.Controls)[
^].
That's all.
Now, please see my comment to the question. In addition to that: many your minor bugs such as this one will go if you simply start to write neat code. Look, right now your code is based on
immediate constants like 1110, 10, 5, 100 and 50. It's apparent that they are interrelated. You should not hard-code, say, shifts, because they are calculated out of number of rectangles and the size. You should calculate everything. Most of your immediate constants should become variables with calculated values, other should become either explicitly declared constants, never repeated, or method parameters. Only then you will be able to maintain your code and will have less bugs.
—SA