TextBox not vertically aligning

I seem to have an issue with TextBox where the text is not vertically aligning properly. In the image below, the title at the top of the window is aligned correctly but the title box with hours. mins etc are not.

This is the code for the TextBox

    var hoursTitle = new TextBox()
    {
        Font = this.fontDroid18,
        Text = "Hours",
        Width = 80,
        Height = 50,
        IsEnabled = false,
        TextAlign = TextAlignment.Center,
        VerticalAlignment = VerticalAlignment.Center,
        Background = new SolidColorBrush(uiColor.FromArgb(0xFF, 0x95, 0xB3, 0xD7)),
        Foreground = new SolidColorBrush(Colors.Black),
    };
    Canvas.SetLeft(hoursTitle, 150);
    Canvas.SetTop(hoursTitle, 85);

By the way, TextAlign is the only way to center align the text. HorizontalAlignment causes it to align to the left.

The vertical alignment also seems to do the same for Text. See image below where the Max Current Limit and mA text is the same height as the TextBox between them but the text always appears top aligned.

Anyone else seeing issues with Text and TextBox vertical alignment?

1 Like