简体   繁体   English

我正在使用WPF TextBlock,但是当文本太长时,文本会被切断。 是否有AutoScroll功能?

[英]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. 我的TextBlock有50x50像素来显示文本,但是如果有更多文本,我希望用户能够滚动。 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. 只需用控件包装textBlock即可。 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中,这样字体就会调整以显示整个文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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