views:

2707

answers:

4

For WPF/Silverlight layout, is it better to use a Grid with lots of rows and columns, or tons of Stackpanels?

A: 

I have no experience with such a layout, but I will bet, that the grid is easier to render compared to lots of nested stackpanels.

ChaosSpeeder
+2  A: 

The container you use should be based on the content and not whether one approach is better than another. If you need things to line up both horizontally and vertically, you really should use a grid. But other than that, it really depends on the content you intend to display.

Rich
A: 

I think the Grid is a better idea. I usually set up the general layout with a Grid and use a few stackpanels here and there to do some specific stuff. I also have a feeling that performance is better with Grids and that Grids generally give you more flexibility.

texmex5
+6  A: 

You should use a Grid if you need things to line up horizontally and vertically. Use a StackPanel to create a row or column of things when those things don't need to line up with anything else.

However, don't limit yourself to those two options. In particular, have a look at the DockPanel. It's slightly more complex than a StackPanel, but its markup isn't as cluttered as the Grid. Here's a good article on the DockPanel:

Using the DockPanel in Silverlight 2

Kyralessa