WPF Grid vs Stackpanel

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


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.


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.