Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stack Panel Or Grid which one is most advisable

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)

like image 939
Rakesh R Nair Avatar asked Mar 15 '11 05:03

Rakesh R Nair


3 Answers

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.

like image 139
Den Delimarsky Avatar answered Oct 23 '22 02:10

Den Delimarsky


Speaking from recent experience, a listbox is the best container class to use. The main benefit is speed as it uses a virtualizing stack panel internally.

I tried both a grid and a stack panel and both were taking 25 seconds to display 60 user controls. This dropped down to 10 seconds after I switched to the listbox.

If you needed the extra positioning, use a grid inside each list item template.

like image 31
Steve Chadbourne Avatar answered Oct 23 '22 04:10

Steve Chadbourne


Grid and Stackpanel each have their place it depends on your UI requirements. Sounds like you are prematurely optimizing.

I would implement the panel that most suits the need and then worry about performance later, if it is an issue.

like image 4
benPearce Avatar answered Oct 23 '22 03:10

benPearce