StackPanel 提供一个从左至右或从上至下放置内容的堆栈模型。
   下面的代码直接拷贝到XamlPad中就可以看到效果(XamlPad在什么地方?安装Framework3.0 SDK就可以了)
2007重整河山系列 WPF---StackPanel Grid<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
2007重整河山系列 WPF---StackPanel Grid  
<Grid>
2007重整河山系列 WPF---StackPanel Grid
<StackPanel Orientation="Horizontal" Background="silver" Margin="20">
2007重整河山系列 WPF---StackPanel Grid
<Label Margin="5" Content="Username" />
2007重整河山系列 WPF---StackPanel Grid
<TextBox
2007重整河山系列 WPF---StackPanel Grid 
Margin="5"
2007重整河山系列 WPF---StackPanel Grid BorderBrush
="Blue"
2007重整河山系列 WPF---StackPanel Grid Foreground
="Black"
2007重整河山系列 WPF---StackPanel Grid Width
="100"/>
2007重整河山系列 WPF---StackPanel Grid
<Button Name="test" Width="100" Height="50" Content="Test"/>
2007重整河山系列 WPF---StackPanel Grid
<Button  Content="中文也是可以的!"/>
2007重整河山系列 WPF---StackPanel Grid
2007重整河山系列 WPF---StackPanel Grid
<Label Name="testlabel"  Content="king"/>
2007重整河山系列 WPF---StackPanel Grid
2007重整河山系列 WPF---StackPanel Grid 
</StackPanel>
2007重整河山系列 WPF---StackPanel Grid  
</Grid>
2007重整河山系列 WPF---StackPanel Grid
</Page>
2007重整河山系列 WPF---StackPanel Grid

 Grid 提供一个允许进行行/网格定位的模型:
2007重整河山系列 WPF---StackPanel Grid<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
2007重整河山系列 WPF---StackPanel Grid  
<Grid>
2007重整河山系列 WPF---StackPanel Grid
<Button  Width="200" Height="60" VerticalAlignment="Bottom" HorizontalAlignment="Right" 
2007重整河山系列 WPF---StackPanel GridMargin
="20"   Content="中文也是可以的!"/>
2007重整河山系列 WPF---StackPanel Grid  
</Grid>
2007重整河山系列 WPF---StackPanel Grid
</Page>
在网格中,可设置列和行定义,从而可以设置宽和高。可将上述项设置为绝对值(x 像素宽),或者在考虑绝对大小调整之后使用星号表示法来分配剩余的空间。还可以设置一个系数来确定分配该空间的方式。例如:
2007重整河山系列 WPF---StackPanel Grid<Border xmlns="http://schemas.microsoft.com/winfx/avalon/2005">
2007重整河山系列 WPF---StackPanel Grid<Grid LayoutTransform="scale 3" ShowGridLines="true">
2007重整河山系列 WPF---StackPanel Grid<ColumnDefinition Width="30" />
2007重整河山系列 WPF---StackPanel Grid<ColumnDefinition Width="2*" />
2007重整河山系列 WPF---StackPanel Grid<ColumnDefinition Width="*" />
2007重整河山系列 WPF---StackPanel Grid<RowDefinition />
2007重整河山系列 WPF---StackPanel Grid<Button Grid.Column="1" Margin="10">Hello world!</Button>
2007重整河山系列 WPF---StackPanel Grid</Grid>
2007重整河山系列 WPF---StackPanel Grid</Border>
可用 SharedSizeGroup 属性为多个对象指定共享的大小。例如,可使用该属性来指定两个按钮具有相同的宽度(即使它们通常具有不同的大小范围)。例如:
2007重整河山系列 WPF---StackPanel Grid<Border xmlns="http://schemas.microsoft.com/winfx/avalon/2005">
2007重整河山系列 WPF---StackPanel Grid<Grid LayoutTransform="scale 2" ShowGridLines="true" IsSharedSizeScope="true" Height="80">
2007重整河山系列 WPF---StackPanel Grid<ColumnDefinition Width="30" />
2007重整河山系列 WPF---StackPanel Grid<ColumnDefinition Width="Auto" SharedSizeGroup="Buttons" />
2007重整河山系列 WPF---StackPanel Grid<ColumnDefinition Width="Auto" SharedSizeGroup="Buttons" />
2007重整河山系列 WPF---StackPanel Grid<RowDefinition />
2007重整河山系列 WPF---StackPanel Grid<Button Grid.Column="1" Margin="10">OK</Button>
2007重整河山系列 WPF---StackPanel Grid<Button Grid.Column="2" Margin="10">A very long cancel button</Button>
2007重整河山系列 WPF---StackPanel Grid</Grid>
2007重整河山系列 WPF---StackPanel Grid</Border>

WrapPanel 模型是资源管理器窗口的右侧窗格,使您可以处理在当前行已满之后流入新行中的项。例如:
2007重整河山系列 WPF---StackPanel Grid<Border xmlns="http://schemas.microsoft.com/winfx/avalon/2005" 
2007重整河山系列 WPF---StackPanel GridLayoutTransform="scale 2">
2007重整河山系列 WPF---StackPanel Grid<WrapPanel Background="Silver" Margin="10">
2007重整河山系列 WPF---StackPanel Grid<Button /> <Button /> <Button /> <Button /> <Button /> <Button /> <Button /> <Button 
2007重整河山系列 WPF---StackPanel Grid/> <Button /> <Button /> <Button /> <Button /> <Button /> <Button /> <Button /> 
2007重整河山系列 WPF---StackPanel Grid<Button /> <Button /> <Button /> <Button /> <Button /> <Button /> <Button /> <Button 
2007重整河山系列 WPF---StackPanel Grid/> <Button /> <Button /> <Button /> <Button />
2007重整河山系列 WPF---StackPanel Grid</WrapPanel>
2007重整河山系列 WPF---StackPanel Grid</Border>

相关文章:

  • 2021-12-13
  • 2022-12-23
  • 2021-07-10
  • 2021-05-31
  • 2022-12-23
  • 2021-06-18
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2021-06-30
  • 2021-12-04
  • 2021-12-05
  • 2021-06-03
相关资源
相似解决方案