title: How can I insert a newline into a TextBlock without XAML?
body: <p>I have created a WPF <code>TextBlock</code> inside a <code>Label</code> <strong>in code</strong> (XAML is not possible in my case) as follows:</p>
  
  <pre><code>Label l = new Label();
  TextBlock tb = new TextBlock();
  l.Content = tb;
  </code></pre>
  
  <p>I then come to a situation where I need to set the <code>.Text</code> property of <code>TextBlock</code> containing a new line, such as:</p>
  
  <pre><code>tb.Text = "Hello\nWould you please just work?";
  </code></pre>
  
  <p>I have tried numerous encodings (HTML encoding, ASCII encoding, etc.) of various newline combinations (carriage return, linefeed, carriage return plus linefeed, linefeed plus carriage return, double linefeed, double carriage return, etc... ad nauseum). </p>
  
  <ul>
  <li>Answers should contain <em>absolutely no XAML</em>.</li>
  <li>Answers should assume that the original objects were created using C# code and <strong>not</strong> XAML.</li>
  <li>Answers should not refer to <em>binding</em> of WPF properties. No binding is being used. The "Text" property of the "TextBlock" object is being <strong>set</strong>. The newline <em>must</em> be inserted <em>there</em>.</li>
  </ul>
  
  <p>If this is impossible, please let me know how I can programmatically add newlines by dynamically replacing each newline in an arbitrary input <code>String</code> into a <code>LineBreak</code> object (or whatever is needed to get this working). The input <code>String</code> will have arbitrary (readable text) contents that I am unable to anticipate in advance because the text itself is dynamic (user-defined); the source strings will have the linefeed character (aka LF, aka <code>\n</code>) but I can easily replace that with whatever is needed.</p>
  
  <p>Also, if it is easier to do this with a <code>Label</code> directly rather than a <code>TextBlock</code> in a <code>Label</code>, that is good too -- I can use that. I just need a control with automatic plain text line wrapping.</p>