Architect's Log

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

Gridの楕円幅を最長のものに合わせる

アプリ実行


ソースコード

App.xaml
<Application x:Class="HelloWorld.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>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <!-- 全ての幅を最長の楕円に合わせる -->
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Ellipse Grid.Row="0" Fill="Aqua" Width="100" />
        <Ellipse Grid.Row="1" Fill="Aqua" />
        <Ellipse Grid.Row="2" Fill="Aqua" />
        <Ellipse Grid.Row="3" Fill="Aqua" />
    </Grid>
</Window>