Bug about Grid

<StackPanel>
&lt;Grid&gt;
// A List of Images
&lt;/Grid&gt;

&lt;Panel&gt;
    // A button
    &lt;Clicked Handler=&quot;AddImagesToList&quot;/&gt;
&lt;/Panel&gt;


I did something like this. When I pressed the button, the list of images would be added more images. And supposed that the height of list would increase and the button would move to the bottom. However, sometimes the button move to an incorrect position. And I think it should be the reason that the Grid could not update the correct height of the image list.

After I change the Grid to dockpanel, it seems work normally.

What you possibly want is to set the number of columns and the default row size for the grid.

<Grid ColumnCount="3" DefaultRow="auto">

With a ColumnCount=3 and no RowCount the grid will place 3 items in a row then start a new row.

The DefaultRow="auto" specifies each row uses auto-sizing, as opposed to the default of proportional sizing.