空白处的 WPF TextWrapping [英] WPF TextWrapping on white spaces

查看:31
本文介绍了空白处的 WPF TextWrapping的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 WPF 中使用 TextBlock,我想在其上使用 TextWrapping,我在 XAML 中所做的如下.

I am using a TextBlock in WPF, on which I want to use TextWrapping, What I have done in XAML is as follows.

<TextBlock TextWrapping="Wrap" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" Margin="5,5,5,5">
                                <TextBlock.Text>
                                    This is just a test. This is just a test.
                                </TextBlock.Text>
                            </TextBlock>

当我运行这段代码时,它会显示这样的输出

When I run this code it shows output like this

This is just a test. Th
is is just a test.

但我只想用空格包裹

This is just a test.
This is just a test.

我无法找到 WPF 显示此行为的原因,我尝试了 WrapWithOverflowIsHyphenationEnabled=true 但没有成功.请帮帮我?

I am unable to find why WPF is showing this behavior, I have tried WrapWithOverflow and IsHyphenationEnabled=true with no success. Please help me out?

推荐答案

Bizz 是对的,这不应该是 Text Wrapping 的行为,只是猜测,您是否将文本从某个地方复制/粘贴到 Visual Studio?在这种情况下,空格可能存在问题,WPF 会以错误的方式包装您的文本.

Bizz is right, this shouldn't be the behavior of Text Wrapping, Just a wild guess, are you copy/pasting text from some where to Visual studio? there might be an issue with white spaces in that case, and WPF will wrap your text in wrong way.

这篇关于空白处的 WPF TextWrapping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆