Remove the C# TextBlock inlines elements padding

为君一笑 提交于 2019-12-11 12:55:53

问题


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.

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?


回答1:


Instead of

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

write the runs in one line like this

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

And the space will be gone.



来源:https://stackoverflow.com/questions/14500146/remove-the-c-sharp-textblock-inlines-elements-padding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!