title: Changing paragraph width in WPF RichTextBox
body: <p>I have a RichTextBox on the form:</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;RichTextBox x:Name="TextArea"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>At runtime I add paragraph with border using this code:</p>
  
  <pre><code>Paragraph p1 = new Paragraph();
  Inline hello = new Run("Hello") { FontSize = 14 };
  Inline world = new Run("World") { FontSize = 20, Foreground = new SolidColorBrush(Colors.Red) };
  Inline helloWorld = new Run(Environment.NewLine + "Hello World");
  p1.Inlines.Add(hello);
  p1.Inlines.Add(world);
  p1.Inlines.Add(helloWorld);
  p1.BorderThickness = new Thickness(1);
  p1.BorderBrush = new SolidColorBrush(Colors.SkyBlue);
  p1.Padding = new Thickness(2);
  this.TextArea.Document.Blocks.Add(p1);
  </code></pre>
  
  <p>The result looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/6l4Ca.png" alt="Current picture"></p>
  
  <p>But I want it to be like this:</p>
  
  <p><img src="https://i.stack.imgur.com/Xrrh1.png" alt="Desired picture"></p>
  
  <p><img src="https://i.stack.imgur.com/G66WP.png" alt="enter image description here"></p>
  
  <p>Is there any simple way to set paragraph width (or outer frame size) equal to its content? </p>