Silverlight学习笔记—3
<Gridx:Name="LayoutRoot"Background="#46461F" ShowGridLines="True"> <Grid.RowDefinitions> <RowDefinition Height="120"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="100"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <TextBlock Grid.Row="0"Grid.Column="0" Text="UserName:" VerticalAlignment="Center" Foreground="White"></TextBlock> <TextBlock Grid.Row="1"Grid.Column="0" Text="Password:" VerticalAlignment="Center" Foreground="White"></TextBlock> <TextBox Grid.Row="0"Grid.Column="1" Width="200" Height="30"HorizontalAlignment="Left"></TextBox> <TextBox Grid.Row="1"Grid.Column="1" Width="200" Height="30"HorizontalAlignment="Left"></TextBox></Grid>
定义一个两行两列的Grid,做一个简单的用户登录的布局,为了明显起见,把ShowGridLines属性设为True,以便能够显示出边框线。同时,我们指定了第一行的高度为120,而第二行的则是剩余的高度,用*来指定。b.StackPanelStackPanel支持用行或列的方式来进行页面布局,默认情况下所有的子元素会垂直的排列显示,如下面的XAML声明三个矩形:
<StackPanelBackground="#46461F"> <Rectangle Fill="#0099FF"Stroke="White" Width="100"Height="50" Margin="10"/> <Rectangle Fill="#0099FF"Stroke="White" Width="100"Height="50" Margin="10"/> <Rectangle Fill="#0099FF"Stroke="White" Width="100"Height="50" Margin="10"/></StackPanel>
当然我们也可以指定为水平排列,通过Orientation属性指定:
<StackPanel Background="#46461F" Orientation="Horizontal">
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。