开发者

Wpf nesting containers

On a window control, my main container is a grid.

My grid ha开发者_Go百科s 2 rows, one row definition is 50*, and the other is 250*.

Now i want to add a right sidebar, lets say with a StackPanel.

I would like to have a ListBox inside the StackPanel that aligns with the 50* grid row, so as the window height gets bigger, the ListBox size will also get bigger.

My question is whether i can achieve this behavior while the ListBox is inside the StackPanel (which is nested inside the grid) or must the ListBox be placed directly inside the grid?


StackPanel does not stretch vertically.

If you must need a wrapping parent container, use a Grid, which will expand in all directions (if you leave the Horizontal- and VerticalAlignment alone of course ;) )

Also check out the Panel Overview on MSDN.

Panel Name       x-Dimension             y-Dimension


- Canvas         Constrained to content     Constrained to content
- DockPanel      Constrained             Constrained
- StackPanel     Constrained             Constrained to content
  (Vertical Orientation)    
- StackPanel     Constrained to content  Constrained 
  (Horizontal Orientation)  
- Grid        Constrained             Constrained, except in cases where Auto apply to rows and columns
- WrapPanel      Constrained to content  Constrained to content
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜