Suny_xinxin
激情加才智折射出潜质

1 Border

Border用于在另一个元素的周围绘制边框、背景。Border只能具有一个子级。若要显示多个子元素,需要将border内放置grid面板或canvas面板.

      注: Border不是Layout,而是Control
 

2 、Grid

            格线画板它类似于table,只不过子元素不用放在单元格中,使用Grid.RowGrid.Column两个附加属性指定子元素在Grid中显示的位置,这是一种非常灵活的布局方式。
   
1列定义,2行定义,3是否显示格线.点击红圈圈的位置添加列.


下面咱们来看一下此方式生成的Xaml

 
<Grid x:Name="LayoutRoot" Background="#FFFFFFFF" ShowGridLines="True">
//行定义  
<
Grid.RowDefinitions>
        <RowDefinition Height="50"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
//列定义
    <
Grid.ColumnDefinitions>
        <ColumnDefinition Width="300"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <TextBlock Grid.Row="0" Grid.Column="0" Text="UserName:" VerticalAlignment="Center" Foreground="#ff000000"></TextBlock>
    <TextBlock Grid.Row="1" Grid.Column="0" Text="Password:" VerticalAlignment="Center" Foreground="#ff000000"></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>

 

3 ScrollViewer当其中显示的内容超过它自身的大小时,就会有滚动条出现。

通过属性HorizontalScrollBarVisibilityVerticalScrollBarVisibility来控制纵向和横向滚动条是否出现

             ScrollViewer 可卷动其中的子元素。由于它与boder类似都只能有一个子元素,因此在大部分的情況下,会在其中放置StackPanelCanvasGrid面板。每次將子元素新增至 ScrollViewer时,新的子元素就会复写现有的子元素。


滚动条:Hidden 隐藏  Disabled 不显示  Auto 自动 Visible 显示

      4 Stackpanel

將子元素沿着一条直线,横向或纵向线条排列.

如果内部设定超过容器大小, StackPanel会裁剪越界部分

    默认情况下所有的子元素会垂直的排列显示,当然我们也可以指定为水平排列,通过Orientation属性

 
<StackPanel Background="black" Orientation="Horizontal">
    <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>

    5 Canvas

它支持绝对位置, 当固定位置设定十分重要时,请使用画布面板。当您调整应用程式的大小时,放置在画布面板上的元素將不会自动调整大小,但是在grid面板上的元素就会自动调整大小

     除了Canvas.TopCanvas.Left两个附加属性外,还有一个Canvas.ZIndex附加属性来改变它们的显示顺序
 
<Canvas Background="#46461F">
    <Rectangle Fill="#0099FF" Width="160" Height="80" Canvas.Top="100" Canvas.Left="100" Canvas.ZIndex="1"/>
    <Rectangle Fill="#FF9900" Width="160" Height="80" Canvas.Top="100" Canvas.Left="100"/>

</Canvas>
posted on 2008-07-17 11:17  suny_xinxin  阅读(419)  评论(0编辑  收藏  举报