WPF TextBlock font resize to fill available space in a Grid
I found a great way to do this using ViewBox
:
<Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> <RowDefinition Height="50" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="100" /> </Grid.ColumnDefinitions> <Viewbox Grid.Row="0" Grid.Column="0" Stretch="Uniform"> <TextBlock Name="tbTest" Background="Yellow" Text="This is some text" /> </Viewbox> <ContentControl Grid.Column="0" Grid.Row="2"> <TextBlock>This is some text</TextBlock> </ContentControl></Grid>