Multi-line TextBox

Hi all,
I’d like to know how to show a multi-line text in a TextBox.
I tried with “\n\r”, “\r\n”, Evvironment.NewLine but none works. The text of the only line shown is terminated with “…” if the TextBox width is lower than the string length.

The old “Text” component has a “TextWrap” property that works, but the center vertical alignment does not.

I init the component like this:

txtMessage = new TextBox()
{
Height = 300,
Width = 150,
Foreground = new SolidColorBrush(Colors.White),
Background = new SolidColorBrush(UI_Colors.Black),
Font = UI_Fonts.UBfont18B,
TextAlign = TextAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Text = strMsg
};

I’d like that it displays single or multiple lines , always centered both vertically and horizontally in the given size (Width, height).

Thanks in advance for any help.

Best,
Vittorio

Try a Text Flow.
https://docs.ghielectronics.com/software/tinyclr/tutorials/user-interface.html#textflow

Hi Skeller,
thank you for the suggestion.

With the TextFlow component I can’t find any way to vertically center-align the text, though.

The text is always top-aligned, even if I set the VericalAligment to center, both if I set a height to the TextFlow or not.

I can measure the height of each line and change the top property of the TextFlow accordingly, to center it, but I was wondering why the VerticalAlignment property does not work.

What I need to achieve is to have the text (single or multiple lines) vertically centered in the Text (with textWrap enabled) or TextFlow component.

Best,
Vittorio