I have a problem in adding in a new line in a TextBox in WinUi3.
I am getting the following data as input:
WEATHERCHECK/It's raining heavily/Start of play delayed for 2 hours 43 mins
For every '/', its supposed to go to a new Line, but not happening.
string[] values = value.Split("/");
foreach(string value1 in values)
{
Commentary.Text += value1 + "\r\n";
}
string[] values = value.Split("/");
string newLine = Environment.NewLine;
foreach(string value1 in values)
{
Commentary.Text += value1 + newLine;
}
XAML for Textbox
<StackPanel Orientation="Horizontal">
<TextBox Height="100" TextWrapping="Wrap" Width="500" x:Name="Commentary" BorderThickness="2" BorderBrush="Black" Foreground="Red" Background="AliceBlue" Text="Commentary" />
</StackPanel>
What can I do to show each part in new Line ?
Solved:
As per Comment from Luuk, I gave AcceptsReturn = "true" in XAML and used the same loop to add "\r\n" at the end and it worked.
Setting AcceptsRetrun to true should o that ? (quote: "true if pressing the ENTER key inserts a new line at the current cursor position; otherwise, the ENTER key is ignored." )