title: WPF: How to make RichTextBox look like TextBlock?
body: <p>How can I make <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx" rel="noreferrer"><code>RichTextBox</code></a> with no Margin, Border, Padding etc. ? In another words to display content in the same way as <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.aspx" rel="noreferrer"><code>TextBlock</code></a> does it ? I have tried this:</p>
  
  <pre><code>&lt;RichTextBox Margin="0" Padding="0" Grid.Row="0" BorderThickness="0" &gt;
      &lt;FlowDocument &gt;
          &lt;Paragraph&gt;LLL&lt;/Paragraph&gt;
      &lt;/FlowDocument&gt;
  &lt;/RichTextBox&gt;
  &lt;TextBlock&gt;LLL&lt;/TextBlock&gt;
  </code></pre>
  
  <p>But the result produces is still not what I want: </p>
  
  <p><img src="https://i.stack.imgur.com/oKGJ6.png" alt="enter image description here"></p>
  
  <p>There is still some space before document content (and also maybe after, on the top or bottom of the document...). How can I remove it ?</p>
  
  <hr>
  
  <p>If you are interested why I need this: I trying to make <a href="https://stackoverflow.com/questions/5796457/create-guitar-chords-editor-in-wpf-from-richtextbox/5797833#5797833">H.B.'s answer</a> to my question <a href="https://stackoverflow.com/questions/5796457/create-guitar-chords-editor-in-wpf-from-richtextbox">Create guitar chords editor in WPF</a> to work with <a href="http://en.wikipedia.org/wiki/Kerning" rel="noreferrer">kerning</a> and I don't want to have unnatural space between characters.</p>
  
  <hr>
  
  <h2>Edit</h2>
  
  <p>So it is not <code>ControlTemplate</code> at least not only that because following code will produce exactly the same result (as the one on the picture above):</p>
  
  <pre><code>&lt;RichTextBox Margin="0" Padding="0" Grid.Row="0" BorderThickness="0"&gt;
      &lt;RichTextBox.Template&gt;
          &lt;ControlTemplate&gt;
              &lt;ScrollViewer Padding="0" Margin="0" x:Name="PART_ContentHost"/&gt;
          &lt;/ControlTemplate&gt;
      &lt;/RichTextBox.Template&gt;
      &lt;FlowDocument PagePadding="0"&gt;
          &lt;Paragraph Padding="0" Margin="0" &gt;LLL&lt;/Paragraph&gt;
      &lt;/FlowDocument&gt;
  &lt;/RichTextBox&gt;
  </code></pre>
  
  <p>And I thought this will be question easy to answer... <strong>Interesting observation:</strong> when I have template set and I set <code>PagePadding="0"</code> on <code>FlowDocument</code> <strong>it displays layout that I want</strong> in the VisualStudio designer - <strong>until I run the demo</strong>. In the demo it is wrong again... And when I close the demo it is wrong again in the designer. This is a small bug of VS or is it actually set to the right layout for a while but then something changes value of <code>PagePadding</code> back to some wrong value ?</p>
  
  <hr>
  
  <h2>Edit#2</h2>
  
  <p>Daniel Rose's edited answer is also not working for me. This is XAML:</p>
  
  <pre><code>&lt;FlowDocument PagePadding="{Binding PagePadding}"&gt;
      &lt;Paragraph x:Name="paragraph" Padding="0" 
          TextIndent="0"  Margin="0,0,0,0" &gt;hello&lt;/Paragraph&gt;
  &lt;/FlowDocument&gt;
  </code></pre>
  
  <p>And this is in code:</p>
  
  <pre><code>public static DependencyProperty PagePaddingProperty =
              DependencyProperty.Register("PagePadding", typeof(Thickness),   typeof(EditableTextBlock),
              new PropertyMetadata(new Thickness(0)));
  
  public Thickness PagePadding {
      get { return (Thickness)GetValue(PagePaddingProperty); }
      set { SetValue(PagePaddingProperty, value); }
  }
  </code></pre>
  
  <p><strong>No changes to the result</strong>. Space remains.</p>
  
  <hr>
  
  <h2>Edit#3</h2>
  
  <p>After adding Two-Way binding as Daniel Rose suggested in his las edit it works. Still I don't really think it is very clear (to have dependency property because I need to keep <code>PagePadding</code> at 0 value). <strong>I think it is a hack - bug workaround.</strong> If somebody has better solution please share it. </p>
  
  <p>Obviously "changing <code>PagePadding</code>" of <code>FlowDocument</code> to <code>0,5</code> is a bug. If somebody has MSDN account it would be nice if they reported this bug.</p>