<Window x:Class="DockPanel控件的使用.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="DockPanel控件的使用" Height="350" Width="525">
<DockPanel LastChildFill="True">
<!--使用Border在TextBlock元素的周围绘制边框和背景-->
<Border Height="25" Background="SkyBlue" BorderBrush="Black"
BorderThickness="1" DockPanel.Dock="Top">
<!--用TextBlock显示文本内容-->
<TextBlock Foreground="Black" Margin="3">1.停靠在顶端</TextBlock>
</Border>
<Border Background="LightPink" BorderBrush="Black" BorderThickness="1"
DockPanel.Dock="Left">
<TextBlock Foreground="Black" Margin="3">2.停靠在左侧</TextBlock>
</Border>
<Border Background="LemonChiffon" BorderBrush="Black" BorderThickness="1"
DockPanel.Dock="Right">
<TextBlock Foreground="Black" Margin="3">3.停靠在右侧</TextBlock>
</Border>
<Border Background="PaleGreen" Height="25" BorderBrush="Black"
BorderThickness="1" DockPanel.Dock="Bottom">
<TextBlock Foreground="Black" Margin="3">4.停靠在底部</TextBlock>
</Border>
<Border Height="25" Background="LightSalmon" BorderBrush="Black"
BorderThickness="1" DockPanel.Dock="Bottom">
<TextBlock Foreground="Black" Margin="3">5.停靠在底部</TextBlock>
</Border>
<Border Background="White" BorderBrush="Black" BorderThickness="1">
<TextBlock Foreground="Black" Margin="3">6.填充剩余空间</TextBlock>
</Border>
</DockPanel>
</Window>
DockPanel控件的使用
最新推荐文章于 2024-03-25 00:45:00 发布