Layout Control

Border: There can be only a subset To display borders, must be placed in the parent Border element around the content.

Property BorderBrush set the border color, border width BorderThickness set, provided the CornerRadius rounded degree (straight line is 90 degrees, 0 degree is the circle).

  <Grid>
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Border Background="LightBlue"
                BorderBrush="Black"
                BorderThickness="20"
                CornerRadius="45"
                Padding="25" 
                Grid.Row="0">
        </Border>
        <Border Background="LightBlue"
                BorderBrush="Black"
                BorderThickness="20"
                CornerRadius="45"
                Padding="25"
                Grid.Row="1">
            <Button Content="999"></Button>
        </Border>
    </Grid>

BulletDecorator: But will align bullets and other objects. BulletDecorator has two attributes: bullet, child.

bullet put a bullet, bullet, and child can have only one control. If the Child object is a the TextBlock , Bullet always aligned with the first line of text. If Child object is not a the TextBlock , Bullet is the Child aligned with the center of the object. (Excerpt from https://lileltp.wordpress.com/2009/08/03/wpf%E4%B9%8B%E5%B8%83%E5%B1%80-bulletdecorator/ )

 <Grid>
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <BulletDecorator  Grid.Row="0"
                          Grid.Column="0"
                          Margin="0,5,0,0"
                          VerticalAlignment="Center"
                          Background="Yellow">
            <BulletDecorator.Bullet>
                <Label> Note: </ Label> 
            </BulletDecorator.Bullet> 
            <- Child elements of the TextBlock -!> 
            <- - the TextWrapping text wrap!> 
            <The TextBlock the Width = " 100 " 
                       the TextWrapping = " Wrap " 
                       the HorizontalAlignment = " Left " 
                       the Foreground = " Purple " > 
     hA hA hA hA hA hA hA hA hA hA hA hA hA hA hA hA hA hA hA hA
             </ the TextBlock> 
        </ BulletDecorator> 
        <= BulletDecorator the Grid.Row "1"
                          Grid.Column="0"
                          Margin="0,5,0,0"
                          VerticalAlignment="Center"
                          Background="Yellow">
            <BulletDecorator.Bullet>
                <Label>备注:</Label>
            </BulletDecorator.Bullet>
            <TextBox Text="奇葩说"></TextBox>
        </BulletDecorator>
    </Grid>

Canvas: Use coordinate absolutely positioned elements. The size of the child element needs to be set. Canvas.Left refers to how much the left relative placement deviation, Canvas.Left above deviation relative layout number, empathy Canvas.Bottem, Canvas.Right.

 <Canvas>
        <Canvas Height="100"
                Width="100"
                Top="0"
                Left="0"
                Background="Red"
                Cursor="Cross"
                >
            <TextBox Text="5555"></TextBox>
        </Canvas>
        <Canvas Height="100"
                Width="100"
                Top="100"                 
                Canvas.Left="100"
                Background="Green" />
        <Canvas Height="100"
                Width="100"
                Top="50"
                Left="50"
                Background="Blue" />
    </Canvas>

DockPanel: docked panel, Dock = "Left" docked on the left, Dock = "Right" docked on the right. LastChildFill is true, then the last element to fill the remaining space.

 <DockPanel LastChildFill="False" HorizontalAlignment="Stretch" VerticalAlignment="Top">
        <Button DockPanel.Dock="Left"
                Content="ButtonLeft"></Button>
        <Button DockPanel.Dock="Top" 
                Content="ButtonTop"></Button>
        <Button DockPanel.Dock="Right"
                Content="ButtonRight"></Button>
        <Button DockPanel.Dock="Bottom"
                Content="ButtonBottom"></Button>
        <Button  Content="LastButton"></Button>
</DockPanel>

Expander: This control displays with a foldable content, and can display the title. When ExpandDirection is Right or Left, should not be set Width.

Header can be a picture, string, and so on.

<!--IsExpanded表示初始状态是否叠起来-->
    <Expander Name="myExpander"
              Background="Tan"
              HorizontalAlignment="Right"
              Header="My Expander"
              ExpandDirection="Down"
              IsExpanded="False"
              Width="100">
        <TextBlock TextWrapping="Wrap">
    Lorem ipsum carrots, enhanced 
    rebates, but they do occaecat time and vitality, such as 
    labor and obesity
         </ TextBlock> 
    </ Expand>

 

Guess you like

Origin www.cnblogs.com/bibi-feiniaoyuan/p/layout.html