0

How to add a new line in the text?

I already have a lot of code and I'm looking for the easiest way not to change the overall structure

Resources:

<system:String x:Key="MyKey1">Line1 \n Line2</system:String>

Code:

<TextBlock>
    u<Run BaselineAlignment="Subscript" FontSize="10">lim</Run> - <Run Text="{Binding TextFromMyKey1}"/>
</TextBlock>

The text from Resources enters TextFormMyKey1

I tested all the solutions and none works:

  • \n
  • pressing enter
  • &#x0a;

Here it should be noted that the text enters as a parameter in Run

<Run Text="{Binding TextFromMyKey1}"/>

NOTE for people who do not read the question:

The replies from the link below don't work here

This question is about putting the text in the <Run> tag

Link to a question that does not answer my problem Newline in string attribute

netDevPol
  • 11
  • 3
  • I don't think someone has anything to do. Why marked as a duplicate if it is not a duplicate and I clearly indicated that those answers in this situation do not work? – netDevPol Dec 21 '21 at 10:05

1 Answers1

0

I'm not that WPF guy, but maybe one of those ideas helps:

  • Write the resource really on multiple line, such it looks like:

    <system:String x:Key="MyKey1">Line1
    Line2</system:String>
    
  • Maybe your control for visualization of the text is not capable of showing line breaks. Are you sure it can?

Oliver
  • 43,366
  • 8
  • 94
  • 151