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>

效果图:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY29vbGZlaXdlYg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

二、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>

效果图:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY29vbGZlaXdlYg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

05-18 21:12