標籤:
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" >
<Rectangle Height="200" Width="200" Fill="Bisque"/>
<StackPanel Orientation="Vertical" >
<StackPanel Orientation="Horizontal">
<Rectangle Height="100" Width="100" Fill="Purple"/>
<StackPanel Orientation="Vertical">
<Rectangle Width="100" Height="50" Fill="red"/>
<Rectangle Width="100" Height="50" Fill="Blue"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<Rectangle Width="100" Height="50" Fill="Brown"/>
<Rectangle Width="100" Height="50" Fill="BurlyWood"/>
</StackPanel>
<Rectangle Height="100" Width="100" Fill="Green"/>
</StackPanel>
</StackPanel>
</StackPanel>
對於StackPanel,我覺得就是劃分地區,對於第一個大的StackPanel
它可以設定走向,和靠近邊界。
1、然後stackpanel裡還可以設定StackPanel其父StackPanel是橫向的,那麼預設就是從左至右,從上面那個例子你就可以看得出來。如果父StackPanel是縱向的,那麼預設就是從上向下排列,上面這個例子也有示範。
2、而且在大的StackPanel上面沒有設定其高度或者是其寬度,這時候的高度就是可以依據其所填控制項的高度決定的,比如說,在這裡面第一個加了一個高為200的矩形,然後這個StackPanel就自適應為200了,相當於是height=“auto”。寬度當然預設成螢幕寬了。
3、orientation是可以設定裡面控制項的走向的,Horizontal就是橫著走向 ,從左向右排列
vertical就是縱向走向,從上向下排列。
Layout2:StackPanel(補交作業)