Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StackPanel vs DataGrid vs DockPanel in WPF

I will need to dynamic generate a square matrix of "boxes"(e.g. 2x2, 3x3 etc.), each containing a textbox and a button. These boxes and text will also resize according the the size of the window. Shall I approach this problem using stackPanel, datagrid or dockpanel and what are their advantages or disadvantages? Appreciate for any suggestion.

Developed by WPF, VS2010.

like image 937
KMC Avatar asked Dec 06 '22 00:12

KMC


1 Answers

I would approach it with a Grid control. Columns and rows inside the grid will auto size based on the size of the grid if you tell it too. Also, the Grid automatically fills the area they're put in to, which sounds like what you're after.

Stack panels aren't very flexible. The basically just put one item next to another with no auto sizing.

The dock panel is good for if you have content that should be fixed to on side and some other content for the centre.

like image 135
Jon Mitchell Avatar answered Dec 11 '22 08:12

Jon Mitchell