简体   繁体   中英

Textblock in Viewbox not multiline

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!

尝试在 TextBlock 上设置宽度(或最大宽度)。

将这些属性添加到您的文本块 TextWrapping="Wrap" - 包装 IsHyphenationEnabled="True" - 用连字符打破这个词

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM