问题
I'm having a bit of a trouble with the autosizing of a text. I read somewhere that if I wanted to achieve that, i need to put my textblock in a viewbox. The problem with that is this way the text isn't split into multiple lines. For example "very very very long text" is almost unreadable, but "simpletext" looks just fine.
<Viewbox Grid.Row="1" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="4" StretchDirection="DownOnly">
<TextBlock
Text="{Binding FieldName}" VerticalAlignment="Center" HorizontalAlignment="Center"
TextWrapping="Wrap" FontWeight="Bold" FontFamily="Nueva Std" />
</Viewbox>
Thank you in advance!
回答1:
Try to set a width (or max width) on the TextBlock.
回答2:
Add these properties to your textblock TextWrapping="Wrap" - wrapping IsHyphenationEnabled="True" - breaking the word with hyphen
回答3:
In this case, here is another solution: take this class and make your own LimitedViewbox version, which will have some LowerStretchLimit property. I think it should work.
来源:https://stackoverflow.com/questions/35995215/textblock-in-viewbox-not-multiline