1

I used this code to make one TextBlock with 2 different fonts:

<TextBlock x:Name="textBlock3" FontSize="48" RelativePanel.Below="textBlock2" Margin="0,20,0,0" FontFamily="Segoe UI" IsTextSelectionEnabled="True">
    <Run x:Name="textBlock3_1">00:00:00</Run>
    <Run x:Name="textBlock3_2" FontSize="20">.00</Run>
</TextBlock>

But it makes the two texts a bit too far apart from each other:

Is there a way to make them come closer? I tried setting the margins, turns out they didn't have a margin property.

EDIT: I also want to figure out how to make textBlock3_2 aligned to the top. I couldn't find this property as well.

Omar Einea
  • 2,478
  • 7
  • 23
  • 35
MythicalCode_
  • 85
  • 1
  • 13
  • I dont know anything about UWP, but maybe you can provide a negative margin on one of the runs? – maccettura Mar 07 '18 at 15:53
  • 2
    Did you check out the following answer? https://stackoverflow.com/questions/11090084/how-to-get-rid-of-whitespace-between-runs-in-textblock – huserben Mar 07 '18 at 18:32

1 Answers1

4

I succeeded to correct it by leaving the two run items on the same line (without spaces between them)

    <TextBlock x:Name="textBlock3" FontSize="48"  Margin="0,20,0,0" FontFamily="Segoe UI" >
        <Run x:Name="textBlock3_1">00:00:00</Run><Run x:Name="textBlock3_2" FontSize="20" BaselineAlignment="TextTop">.00</Run>
    </TextBlock>

Edit: I added an extra property for your additional request

Oxald
  • 837
  • 4
  • 10