Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

Gridの列と行を割合で指定する

アプリ実行


ソースコード

App.xaml
<Application x:Class="WpfApplication4.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
</Application>
MainWindow.xaml
<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="300" Width="500">
    <Grid>
        <Grid.RowDefinitions>
            <!-- 2:1の割合 -->
            <RowDefinition Height="2*" />
            <RowDefinition Height="1*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>
        <Ellipse Grid.Row="0" Grid.Column="0" MinWidth="0" Fill="Aqua" />
        <Ellipse Grid.Row="0" Grid.Column="1" MinWidth="0" Fill="Aqua" />
        <Ellipse Grid.Row="1" Grid.Column="0" MinWidth="0" Fill="Aqua" />
        <Ellipse Grid.Row="1" Grid.Column="1" MinWidth="0" Fill="Aqua" />
    </Grid>
</Window>