简体   繁体   中英

Remove the C# TextBlock inlines elements padding

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM