DockPanel布局

WPF基本来说是一个做界面的新技术,它把source同界面分离。

DockPanel:用于设计界面布局                                                                                                                               

可以在Window中设置多个DockPanel将Window分成若干个区域(DockPanel支持嵌套)

eg:   

<DockPanel Width="20" Background="Cornsilk"/>
  <DockPanel Width="800" Height="600">
   <Border DockPanel.Dock="Top">
    <Image Margin="10" Name="currentImage" />
   </Border>
  </DockPanel>
 </DockPanel>
这样就将Window分成了两个区域

Border

在DockPanel中可以用DockPanel和Border对DockPanel进行分割   

 <DockPanel Background="DarkSeaGreen" LastChildFill="True">
  <Border DockPanel.Dock="Right" Width="200" Margin="10" Background="Green">
    <Border Style="{StaticResource DarkVerGradient}">
     <TextBlock Style="{StaticResource Header1}" Text="Select An Image:" />
    </Border>
    ... 

    <StackPanel Background="#E5E5E5" Margin="0,10,0,10">
     <Border Style="{StaticResource DarkVerGradient}">
      <TextBlock Style="{StaticResource Header1}" Text="METADATA" />
     </Border>
     <TextBlock Style="{StaticResource Header2}" Text="Image Size"/>
     <TextBlock Style="{StaticResource Normal}" Name="imageSize" />
     <TextBlock Style="{StaticResource Header2}" Text="Pixel Format"/>
     <TextBlock Style="{StaticResource Normal}" Name="imageFormat" />
     <TextBlock Style="{StaticResource Header2}" Text="File Size"/>
     <TextBlock Style="{StaticResource Normal}" Name="fileSize" />
    </StackPanel>
   </StackPanel>
  </Border>
    <Border DockPanel.Dock="Left" Width="20" Background="Chocolate"/>
   
    <DockPanel Width="20" Background="Cornsilk"/>
   
  <DockPanel Width="800" Height="600" Background="Maroon">
   <Border DockPanel.Dock="Top">
    <Image Margin="10" Name="currentImage" />
   </Border>
  </DockPanel>
   
 </DockPanel>
Border 也可以进行嵌套

    <Border DockPanel.Dock="Left" Width="20" Background="Chocolate">
      <Border Width="10" Background="Red" DockPanel.Dock="Right"></Border>
    </Border>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值