WPF - Resizing Children to Fill a Parent

In WPF, I just want to have a โ€œcontainerโ€ that has 3 text blocks. I would like these 3 text blocks to be sorted so that each one occupies 1/3 of the width of the parent. I noticed that the glass panel automatically determines the last child, but is there a way to automatically cut each child?

+7
source share
1 answer

Use Grid or UniformGrid

<Grid HorizontalAlignment="Stretch"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBlock Text="1" Grid.Column="0"/> <TextBlock Text="2" Grid.Column="1"/> <TextBlock Text="3" Grid.Column="2"/> </Grid> 

The grid is very common, and is used a lot in every WPF application. However, UniformGrid is very convenient, but not so well known.

+18
source

All Articles