删除C#TextBlock内联元素填充 [英] Remove the C# TextBlock inlines elements padding

查看:194
本文介绍了删除C#TextBlock内联元素填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于C#中的TextBlock UIElement,我们可以向其中添加几个Run对象,这些对象将附加到inlines属性中.这是我们在一个TextBlock中显示具有不同格式(字体,大小等)的几段文本的一种方式.

About TextBlock UIElement in C#, we could add several Run object into it, which will be appended to inlines property. That's one way we show several pieces of text with different format(font, size and etc) in one TextBlock.

我的问题是:当我将两个Run对象添加到一个TextBlock中时,每个Run对象之间都存在一个填充.例如,我添加"12"和"34" Run对象,最后它们在视图中将显示为"12 34".但是我需要的是它们应该以一个词"1234"连接在一起,而无需填充

My question is: when I add, such as, two Run object into one TextBlock, there exist a padding between each Run object. For example, I add "12" and "34" Run objects, and finally they will be shown as "12 34" in the view. But what I need is they should be connected together as one word - "1234" - without that padding

我们可以使用任何设置来防止这种填充吗?

Is there any setting we can use to prevent this padding?

推荐答案

代替

<TextBlock>
    <Run Text="12"/>
    <Run Text="34"/>
</TextBlock>        

像这样将运行写成一行

<TextBlock>
    <Run Text="12"/><Run Text="34"/>
</TextBlock>

然后空间就会消失了.

这篇关于删除C#TextBlock内联元素填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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