在开始和结束时设置的TextBlock为preserve空白? [英] Set TextBlock to preserve white space at the beginning and at the end?

查看:215
本文介绍了在开始和结束时设置的TextBlock为preserve空白?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面实际上是code工作,因为我想要的 - 这个问题有点误导。请忽略它。

The code below actually works as I want - this question a little misleading. Please ignore it.

通常,当我设置了的TextBlock 文本属性是这样的:

Normally when I set Text property of TextBlock like this:

TextBlock tb = new TextBlock();
tb.Text = "     Hello World ";

在开始和在文本结尾的空白未示出。通过的TextBlock 显示的文字是唯一的Hello World 。如何设置的TextBlock 来显示它们(即不删除空格)?我丢失了一些财物?

The whitespace at the beginning and at the end of text are not shown. The text shown by TextBlock is only Hello World. How can I set TextBlock to display them (i.e., not remove the whitespace)? Am I missing some property?

推荐答案

在这种情况下,你不需要使用 XML:空间=preserve

In this case you don't need to use xml:space="preserve"

<TextBlock xml:space="preserve" Text="     Hello world!    " />

将显示空格,但是

WILL display the whitespaces, however

<TextBlock>    Hello world!    </TextBlock>

不会。

这篇关于在开始和结束时设置的TextBlock为preserve空白?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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