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 IsSharedSizeScope="true">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" SharedSizeGroup="a" />
            <ColumnDefinition Width="Auto" SharedSizeGroup="a" />
        </Grid.ColumnDefinitions>
        <Ellipse Grid.Row="0" Grid.Column="0" Fill="Aqua" Width="100" />
        <Ellipse Grid.Row="0" Grid.Column="1" Fill="Aqua" />
        <Ellipse Grid.Row="1" Grid.Column="0" Fill="Aqua" />
        <Ellipse Grid.Row="1" Grid.Column="1" Fill="Aqua" />
    </Grid>
</Window>