Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF文本在空白处换行_Wpf_Textblock_Word Wrap - Fatal编程技术网

WPF文本在空白处换行

WPF文本在空白处换行,wpf,textblock,word-wrap,Wpf,Textblock,Word Wrap,我在WPF中使用一个TextBlock,我想在其上使用TextWrapping,我在XAML中所做的工作如下 <TextBlock TextWrapping="Wrap" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" Margin="5,5,5,5"> <TextBlock.Text>

我在WPF中使用一个TextBlock,我想在其上使用TextWrapping,我在XAML中所做的工作如下

<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>
但我只想在空白处包装,比如

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

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

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

不应该发生这种情况。我唯一的猜测是,它的父对象之一正在设置一个特定的属性,而WPF正在将其投影到TextBlock的属性。在直接放在窗口中的网格上尝试您的代码,看看问题是否仍然存在。@Bizz,该属性是什么?知道吗?我不知道。但如果你在最简单的情况下检查它,至少你知道这是因为你的代码,它与操作系统或.Net构建相关。谢谢@madni的建议,我粘贴了google translate的文本,令人惊讶的是,它对空格字符做了一些坏事,我只是用实际空格替换了空格,效果很好。:)
This is just a test.
This is just a test.