title: WPF FlowDocument :: How Can I Define Custom Templates for the Child Paragraph, Run, etc
body: <p>I'm fairly new to WPF, so please bear with me.</p>
  
  <p>I am trying to customize the presentation of the various elements of a <code>FlowDocument</code> in a <code>RichTextBox</code> (RTB).  WPF controls are lookless, so as I understand it I should be able to define the look for every child in the <code>Document</code>.</p>
  
  <p>Would I define the template for this in the RTB?  Separate templates for each item (<code>Paragraph</code>, <code>Section</code>, <code>Run</code>, etc) as resources?  <strike>Let's say, for sake of argument, that I want a red border around every <code>Section</code>, the word "Paragraph:" before every <code>Paragraph</code> with a <code>Margin="5"</code>, and every <code>Run</code> to be in Consolas.</strike> (see edit one) </p>
  
  <p><strong>EDIT ONE</strong>:</p>
  
  <p>I learn more here from asking the <em>wrong</em> question than the right one.  It seems I never ask what I'm really trying to do the first time out the gate.  Who knows, maybe I'll learn.</p>
  
  <p>I am trying to define a <code>DataTemplate</code> or an <code>ItemTemplate</code> (I think) similar to a <code>ListBox</code>.  The ultimate goal is a "source view" HTML editor in an RTB.  I want a Paragraph XAML element to render like this in the RTB:</p>
  
  <pre><code>&lt;p&gt;
    Lorem ipsum stackus overflowum 
  &lt;/p&gt;
  </code></pre>
  
  <p>... and a Run would render like this:</p>
  
  <pre><code>&lt;span style="font-weight:bold"&gt;clarity is important when asking questions&lt;/span&gt;
  </code></pre>
  
  <p>... and so on with the different XAML elements.</p>