简体   繁体   中英

What is a correct application of grid(s) for a label/textbox combination?

I'm going to build a matrix of inputs - five column by three rows. Each input consists of two elements: one label and one input box (or possibly a date picker and such, nothing complicated). I can't decide between the markup, though.

Option #1 is to go 5 by 6 (each row is either a label row or text box row). Option #2 is to use 5 by 3 on the grid and in each cell have a 1 by 2 grid (or possibly a stack panel or such).

  1. Is the option #1 or #2 best practice?
  2. Is the stack panel the correct choice?

I would use the grid 5x3 and inside each cell StackPanel or Grid. It depends on how your application should interact with the user (for example if the size is changed, etc.).

Grid defines a flexible grid area that consists of columns and rows. This can be the most performance intensive panel if proportional sizing or auto sizing is used. Calculating child item size can be a complex combination of the native size of the item and the layout specified by the grid. Layout is also the most complicated of all the panels. Slow to medium performance for the measure pass and slow to medium performance for the arrangement pass.

StackPanel Arranges child elements into a single line that can be oriented horizontally or vertically. The StackPanel measures its children using either native or relative sizing in the opposite direction from its orientation and native sizing in the direction of its orientation (alignment does nothing in this direction). This makes it a mid-level performer in this area. The Arrangement pass is simply, just laying out the items in order. Probably the second-best performance for this pass. Medium performance for the measure pass and fast performance for the layout pass.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM