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)
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With