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

        <Border Background="Aqua">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50" />
                    <RowDefinition Height="50" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="a" />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Ellipse Grid.Row="0" Grid.Column="0" Fill="Red" />
                <Ellipse Grid.Row="0" Grid.Column="1" Fill="Red" Width="20" />
                <Ellipse Grid.Row="1" Grid.Column="0" Fill="Red" />
                <Ellipse Grid.Row="1" Grid.Column="1" Fill="Red" />
            </Grid>
        </Border>
    </StackPanel>
</Window>