<StackPanel />
Stack-----堆,默认为从上到下。可通过属性Orientation="Horizontal "设置为左到右,
但一般不这么做。左到右使用下面的<DockPanel>
<DockPanel>
<Button DockPanel.Dock="Top|Right|Bottom|Left" Content="Button 1" />
<TextBox DockPanel.Dock="Top|Right|Bottom|Left" Content="This is my content" />
</DockPanel>
Dock---码头,默认为从左到右
<StackPanel>和<DockPanel>都可以使用下面的追加属性。
HorizontalAlignment (水平队列)= LEFT/RIGHT/ CENTER/ STRETCH
VerticalAlignment (垂直队列)=TOP/ BOTTOM/ CENTER/ STRETCH
<DockPanel>
<StackPanel VerticalAlignment ="Bottom ">
<Label HorizontalAlignment="Right " Width="100 ">
Username
</Label>
</StackPanel>
</DockPanel>
<Grid ShowGridLines="true " >
<Grid.ColumnDefinitions >
<ColumnDefinition Width="Auto "> </ColumnDefinition>
<ColumnDefinition Width="Auto "> </ColumnDefinition>
</Grid.ColumnDefinitions >
<Grid.RowDefinitions>
<RowDefinition Height="Auto " />
<RowDefinition Height="Auto " />
</Grid.RowDefinitions>
<Label
Grid.Row ="0 "
Grid.Column ="0 "
Width="100 ">Username </Label>
<TextBox
Grid.Row ="1 "
Grid.Column ="1 "
Width="150 ">username@example.com</TextBox>
</Grid>
<Canvas>
<Canvas Canvas.Top="100" Canvas.Left="200">
<Label Canvas.Top="0" Canvas.Left="0" Background="Red">0,0</Label>
<Label Canvas.Top="0" Canvas.Left="100" Background="Red">0,100</Label>
</Canvas>
<Label Canvas.Left="100" Canvas.Top="100">100,100</Label>
<Label Canvas.Left="0" Canvas.Top="100">0,100</Label>
</Canvas>
画边框:
<Border
Height="25"(只能设置边框的高度。宽度由系统自动生成)
BorderBrush="Black"
BorderThickness="1"
Padding="2 2 2 2">
</Border>
Border(边框)内只能有一个子元素