Border:只能有一个子集,如要在内容周围显示边框,必须放在父Border元素中。
属性BorderBrush设置边框颜色,BorderThickness设置边框宽度,CornerRadius设置圆角程度(90度就是直线,0度就是圆)。
<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:将项目符号与另一个可是对象对齐。BulletDecorator有两个属性:bullet、child。
bullet放的是项目符号,bullet和child都只能有一个控件。如果 Child 对象是一个 TextBlock, Bullet 始终与第一行文本对齐。如果 Child 对象不是一个 TextBlock, Bullet 则与 Child 对象的中心对齐。(摘自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>备注:</Label>
</BulletDecorator.Bullet>
<!--TextBlock为Child元素-->
<!--TextWrapping文本进行换行-->
<TextBlock Width="100"
TextWrapping="Wrap"
HorizontalAlignment="Left"
Foreground="Purple">
哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
</TextBlock>
</BulletDecorator>
<BulletDecorator 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:使用坐标绝对定位元素。子元素的大小需要设置。Canvas.Left指相对布局的左边偏离多少,Canvas.Left相对布局的上面偏离多少,同理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:停靠面板,Dock="Left"停靠在左边,Dock="Right"停靠在右边。 LastChildFill为true,则最后一个元素填充剩下的空间。
<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:该控件显示具有可折叠内容,并可以显示标题。当ExpandDirection为Right或Left,则不应该设置Width。
Header可以是图片、字符串等。
<!--IsExpanded表示初始状态是否叠起来-->
<Expander Name="myExpander"
Background="Tan"
HorizontalAlignment="Right"
Header="My Expander"
ExpandDirection="Down"
IsExpanded="False"
Width="100">
<TextBlock TextWrapping="Wrap">
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua
</TextBlock>
</Expander>
原文:https://www.cnblogs.com/bibi-feiniaoyuan/p/layout.html