How to align separate Grids created via templates along their columns / rows?

I thinks that in this case A picture is worth a thousand words:

alt text

XAML:

 <Grid>
    <ItemsControl ItemsSource="{Binding Persons}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding Name}" Background="LightBlue"/>
                    <TextBlock Text="{Binding Age}" Background="LightPink" Grid.Column="1"/>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</Grid>

p.s - I don't want to set a specific with to the first column, but to give it the max with that it needs.

Update: Я попробовал ссылку ColinE и сделал следующее:

 <Grid.ColumnDefinitions>
                        <ColumnDefinition SharedSizeGroup="A" Width="Auto"/>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

, но у меня это не сработало.

9
задан H.B. 31 August 2011 в 14:04
поделиться