Visual Studio / WPF > UniformGrid > Provides a way to arrange content in a grid where all the cells in the grid have the same size.


Visual Studio 2017 Community (以下VS)
Windows 7 Pro (32bit)

Silverlight 2には存在せず、WPFでのみ利用可能なPanelとして、DockPanel、UniformGrid、WrapPanelなどが存在する。

UniformGridについて調べた。
https://stackoverflow.com/questions/6197646/understanding-uniform-grid-control

MSDN: https://msdn.microsoft.com/ja-jp/library/system.windows.controls.primitives.uniformgrid(v=vs.110).aspx

Provides a way to arrange content in a grid where all the cells in the grid have the same size.

実装してみた。

MainWindow.xaml
<Window x:Class="_170530_t1500_uniformGrid.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:_170530_t1500_uniformGrid"
        mc:Ignorable="d"
        Title="MainWindow" Height="200" Width="525">
    <Grid>
        <UniformGrid Rows="3" Columns="4">
            <Button Content="1" Height="40"/>
            <Button Content="2" Height="40"/>
            <Button Content="3" Height="40"/>
            <Button Content="4" Height="40"/>
            <Button Content="5" Height="40"/>
            <Button Content="6" Height="40"/>
            <Rectangle Fill="Aqua"/>
            <Button Content="8" Height="40"/>
            <Rectangle Fill="Aqua"/>
        </UniformGrid>
    </Grid>
</Window>

Gridを使う場合と比べて、宣言順にインスタンスが配置されていく点は便利かもしれない。