There are several ways to accomplish what you're trying to do here. If performance is not an issue then I would ignore virtualization and try the DockPanel
The drawback here is that you would have to add the items in order rather than adding them by row.
Another option would be to use two stack panels (one in each direction). This addresses the adding issue, but requires the use of more panels.
Both of the previous two options would require individual items to have their height/width set.
A final option (depending on how large your grid is), would be to use a Grid with fixed sized rows and columns with items that span rows (using the rowspan property). The drawback of this method is that I don't know of any good way to create this control in xaml for unspecified numbers of rows/columns so you would have to create it in code to get the needed number of rows/columns.
If you have performance issues you could try using the VirtualizingStackPanel. If this still doesn't meet your performance requirements then you will need to subclass the VirtualizingPanel
and tailor it to meet your specific needs.
See here for more information on Panel performance.
I suggest trying the two StackPanel
method first, then the VirtualizingStackPanel
method and finally, if that doesn't work, then try the VirtualizingPanel
Padding is easily accomplished by setting the Margin
property on each subcontrol.
For scrolling use the ScrollViewer