4

Text="Some text:" I want to add a space after the colon.

I've tried xml:space="preserve" and   but neither seems to work.

I know it can be done by adding margin, but I'm curious if there's another way.

Amy Peng - MSFT
  • 1,902
  • 11
  • 14
Viktor Simkó
  • 2,607
  • 16
  • 22

3 Answers3

10

Try this, it works for me.

<RelativePanel>
    <TextBlock x:Name="test1" RelativePanel.Below="edLongitude">
        ahoj &#160;  
    </TextBlock>
    <TextBlock x:Name="test2" RelativePanel.Below="edLongitude" RelativePanel.RightOf="test1" Text="nazdar" />
</RelativePanel>
Ive
  • 1,321
  • 2
  • 17
  • 25
4

Another alternative is using Run:

<TextBlock Foreground="Black">
    <Run Text="SomeText:"/>
    <Run/>
</TextBlock>

The Run element on a new line will add the space, but if you write the two Runs on the same line, the space will not be created:

<TextBlock Foreground="Black">
    <Run Text="SomeText:"/><Run/>
</TextBlock>
Kristian Vukusic
  • 3,284
  • 6
  • 30
  • 46
3

Easiest thing would just be applying a margin - any reason you can't do that?

<TextBlock Text="MyText" Margin="0 0 8 0" />
Deeko
  • 1,514
  • 9
  • 29