title: How to display search results in a WPF items control with highlighted query terms
body: <p>I'd like to display search results within a WPF ItemsControl with the query terms highlighted.</p>
  
  <p>The search engine I use, <a href="http://incubator.apache.org/lucene.net/" rel="noreferrer">Lucene.Net</a> with the Highlighter plugin, returns strings with the query terms marked up like so:</p>
  
  <pre><code>...these &lt;Bold&gt;results&lt;/Bold&gt; were found to be statistically significant...
  </code></pre>
  
  <p>I can instruct the Highlighter plugin to use any set of markup tags to wrap a query term. I'm not limited to the <code>&lt;Bold&gt;</code> tag in the example above. For WPF, I'd likely make these <code>&lt;Run/&gt;</code> elements with a style attached.</p>
  
  <p>The challenge is to take the string I've been given and render it as if it were "actual XAML" within the datatemplate I'm using for search results. In other words, I want to see something like this:</p>
  
  <blockquote>
    <p>...these <strong>results</strong> were were found to be statistically significant...</p>
  </blockquote>
  
  <p>But I'm struggling with how to combine databinding with dynamic rendering of an XAML string within the datatemplate. What's the best approach here?</p>
  
  <ol>
  <li>Use a UserControl to display each search result and call <code>XamlReader.Load()</code> from the codebehind?</li>
  <li>Construct a FlowDocument containing the search result strings and display the results with a FlowDocumentScrollViewer?</li>
  <li>Something else entirely...?</li>
  </ol>