WPF 布局控件 之 DockPanel

DockPanel为容器控件

主要了解其Dock属性和LastChildFill属性的使用

一、LastChildFill="True" 时

代码:

<DockPanel LastChildFill="True">
            <Button DockPanel.Dock="Top">Top</Button>
            <Button DockPanel.Dock="Bottom">Bottom</Button>
            <Button DockPanel.Dock="Left">Left</Button>
            <Button DockPanel.Dock="Right">Right</Button>
            <Button>Fill</Button>
 </DockPanel>

效果图:


二、LastChildFill="False"时

代码:

        <DockPanel LastChildFill="False">
            <Button DockPanel.Dock="Top">Top</Button>
            <Button DockPanel.Dock="Bottom">Bottom</Button>
            <Button DockPanel.Dock="Left">Left</Button>
            <Button DockPanel.Dock="Right">Right</Button>
            <Button>Fill</Button>
        </DockPanel>
效果图:




原文地址:https://www.cnblogs.com/liguangsunls/p/6946736.html