WPF基础入门
Class1:布局
1、Grid行列结构
*:按比例设置宽高,eg:0.6*
<Grid>
<!--两行两列-->
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
2、Grid.Column、Grid.ColumnSpan、Grid.Row、Grid.RowSpan的行列选中,在<Grid.ColumnDefinitions>同目录下:
<Button Width="100" Height="50" Name="SB" Content="SB"></Button>
<Border Grid.RowSpan="2" Grid.Column="0" Background="YellowGreen"></Border>
<Border Grid.Row="0" Grid.Column="1" Background="AntiqueWhite"></Border>
<!--<Border Grid.Row="1" Grid.Column="0" Background="Aqua"></Border>-->
<Border Grid.Row="1" Grid.Column="1" Background="Aquamarine"></Border>
3、其他容器:
StackPanle:
Orientation=排列方向,超出的不会自动换行,会被隐藏
<StackPanel Orientation="Horizontal">
<Button Width="100" Height="40" Click="Button_Click"></Button>
<Button Width="100" Height="40"></Button>
<Button Width="100" Height="40"></Button>
<Button Width="100" Height="40"></Button>
<Button Width="100" Height="40"></Button>
</StackPanel>
WrapPanel
默认水平排列 ,超出的自动排列
<WrapPanel Grid.Row="1">
<Button Width="100" Height="40"></Button>
<Button Width="100" Height="40"></Button>
<Button Width="100" Height="40"></Button>
<Button Width="100" Height="40"></Button>
<Button Width="100" Height="40"></Button>
<Button Width="100" Height="40"></Button>
</WrapPanel>
DockPanel
可控制靠边文章来源:https://www.toymoban.com/news/detail-665979.html
<DockPanel Grid.Column="1" LastChildFill="False">
<Button Width="100" Height="40" DockPanel.Dock="Right"></Button>
<Button Width="100" Height="40" DockPanel.Dock="Bottom"></Button>
<Button Width="100" Height="40" DockPanel.Dock="Top"></Button>
<Button Width="100" Height="40" DockPanel.Dock="Left"></Button>
</DockPanel>
文章来源地址https://www.toymoban.com/news/detail-665979.html
到了这里,关于WPF基础入门-Class1的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!