佈局篇-WrapPanel佈局

 WrapPanel內部採用流式佈局,使用orientation屬性控制流延伸方向,用HorizontalAlignment和VerticalAlignment兩個屬性控制內部控件的對齊,例子如下

    <WrapPanel>
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
        <Button Width="50" Height="50" Content="OK" />
    </WrapPanel>


效果如下,改變窗口大小,內部控件的位置會自動調整

 

同樣的代碼,改成垂直佈局後的效果

發佈了26 篇原創文章 · 獲贊 21 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章