Example:

<TextBlock>    <Run Text="("/>    <Run Text="Text"/>    <Run Text=")"/> </TextBlock> 

Expected:

(Text)

Result:

(Text)

  • Tell me - and if you have 20 different tags used in XAML - will you put 20 tags on the question? :) - Pavel Mayorov
  • And yes, does TextBlock inside TextBlock invest properly? - Pavel Mayorov
  • @PavelMayorov, the question concerns precisely the work of TextBlock with nested tags. Therefore, the label "TextBlock" is needed. All tags that can be placed inside the TextBlock list does not make sense. - Kibnet Philosoff
  • @PavelMayorov; The WPF philosophy does not prohibit TextBlock from investing inside TextBlock. Therefore, the question of correctness is incorrect. But still, for you, I corrected the tags on Run. - Kibnet Philosoff

1 answer 1

If the Run blocks in the markup are on different lines, then they are separated by a space from each other.

This happens because the newline character inside the TextBlock is converted to a space.

The solution of the problem is their placement in one line:

 <TextBlock>   <Run Text="("/><Run Text="Text"/><Run Text=")"/> </TextBlock> 

Or:

 <TextBlock>   (<Run Text="Text"/>) </TextBlock> 

The result in both cases will be without spaces:

(Text)

  • @VladD, in the second case there will be no spaces, I checked. You can try. - Kibnet Philosoff
  • Hmm, really. Sorry, wrong. - VladD
  • @VladD, it happens ... thanks for trying. ;) - Kibnet Philosoff