简体   繁体   中英

I'm using a WPF TextBlock but then text gets cut off when it's too long. Is there an AutoScroll feature?

My TextBlock has for example 50x50 pixels to display text, however if there is more text, I want a user to be able to scroll. Is there an autoscroll feature for this control?

Should I use a different control better suited for this task?

Here's a couple of pics to illustrate the problem:

This one works fine because the text fits in snugly: 替代文字

This one doesn't seem correct. Text is cut off. 替代文字

Just in case someone comes into the same problem. Just wrap the textBlock with a control. Works like a charm!

<ScrollViewer Background="Black">
    <TextBlock x:Name="textBlockBackStory" 
               FontSize="12" 
               Foreground="Orange" 
               TextWrapping="Wrap"                       
               Background="Black" 
               TextDecorations="None">
                            Backstory here.
    </TextBlock>      
</ScrollViewer>

您可以将文本块放在ViewBox中,这样字体就会调整以显示整个文本。

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