StackPanel in Silverlight

I.Introduction

StackPanel là một Layout Control giúp các bạn bố trí giao diện theo dạng Stack.

StackPanel có thuộc tính đáng chủ ý là Orienttation. Tùy theo nhu cầu mà các bạn chọn :

Orientation="Horizontal"

Orientation="Vertical"

Các bạn sẽ hiểu rõ hơn ở Phần Demo phía sau.

II.Creating Project And Coding

Open VS 2010 và tạo Silverlight Project.

image

Tiếp theo các bạn Kéo thả Stackpanel Từ ToolBox vào Project và thêm một vài Rectangle vào StackPenel.

Horizontal

   1: <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="11,143,0,0" Name="stackPanel1" VerticalAlignment="Top">

   2:             <Rectangle Width="100" Fill="AntiqueWhite" Height="100"/>

   3:             <Rectangle Width="100" Fill="Azure" Height="100"/>

   4:             <Rectangle Width="100" Fill="AliceBlue" Height="100"/>

   5:             <Rectangle Width="100" Fill="Blue" Height="100"/>

   6:             <Rectangle Width="100" Fill="BlueViolet" Height="100"/>

   7:             <Rectangle Width="100" Fill="Coral" Height="100"/>

   8:         </StackPanel>

image

Vertical

   1: <StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="11,143,0,0" Name="stackPanel1" VerticalAlignment="Top">

   2:             <Rectangle Width="100" Fill="AntiqueWhite" Height="100"/>

   3:             <Rectangle Width="100" Fill="Azure" Height="100"/>

   4:             <Rectangle Width="100" Fill="AliceBlue" Height="100"/>

   5:             <Rectangle Width="100" Fill="Blue" Height="100"/>

   6:             <Rectangle Width="100" Fill="BlueViolet" Height="100"/>

   7:             <Rectangle Width="100" Fill="Coral" Height="100"/>

   8:         </StackPanel>

image

Leave a comment