Stack Panel Or Grid which one is most advisable

Rakesh R Nair picture Rakesh R Nair · Mar 15, 2011 · Viewed 16.8k times · Source

I heard that UI Design with Stack panel is more promotable that Grids. Is there any fact present in that. I am usually using Grid for Designing my UI, recently in a document i read that the Grid consumes more time for rendering rather than stack panel ;; so i am very much confused about this.. Please give me more informations about this.. (WP7 Development)

Answer

Den Delimarsky picture Den Delimarsky · Mar 15, 2011

In a Grid, elements can be positioned relatively to each-other, being free to generally move around (if the developer wants to do so). A Grid doesn't enforce specific positioning unless explicitly specified. In a StackPanel the controls are obviously, stacked. So if in a Grid you would add two controls in a single sequence, those will be overlapping. In a StackPanel, the controls will be placed one after another, be it horizontally or vertically.

Generally, there is no performance overhead when it comes to choosing between Grid or StackPanel. A benefit of the Grid control is that there is a possibility to explicitly define rows and colums, which ultimately leads to the possibility of creating more complex layouts. Each has its place and are generally not interchangeable.