删除C#TextBlock内联元素填充 [英] Remove the C# TextBlock inlines elements padding
问题描述
关于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屋!