Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's an example using a nested ItemsControl. Unfortunately, it will make one TextBlock per Inline instead of putting the whole Paragraph into one TextBlock:</p> <pre><code>&lt;Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;Grid.Resources&gt; &lt;FlowDocument x:Key="document"&gt; &lt;Paragraph&gt;&lt;Run xml:space="preserve"&gt;This is the first paragraph. &lt;/Run&gt;&lt;Run&gt;The quick brown fox jumps over the lazy dog.&lt;/Run&gt;&lt;/Paragraph&gt; &lt;Paragraph&gt;&lt;Run xml:space="preserve"&gt;This is the second paragraph. &lt;/Run&gt;&lt;Run&gt;Two driven jocks help fax my big quiz.&lt;/Run&gt;&lt;/Paragraph&gt; &lt;Paragraph&gt;&lt;Run xml:space="preserve"&gt;This is the third paragraph. &lt;/Run&gt;&lt;Run&gt;Sphinx of black quartz, judge my vow!&lt;/Run&gt;&lt;/Paragraph&gt; &lt;/FlowDocument&gt; &lt;DataTemplate DataType="{x:Type Paragraph}"&gt; &lt;ItemsControl ItemsSource="{Binding Inlines}" IsHitTestVisible="False"&gt; &lt;ItemsControl.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;WrapPanel/&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ItemsControl.ItemsPanel&gt; &lt;/ItemsControl&gt; &lt;/DataTemplate&gt; &lt;/Grid.Resources&gt; &lt;ListBox ItemsSource="{Binding Blocks, Source={StaticResource document}}"/&gt; &lt;/Grid&gt; </code></pre> <p>If you want one Paragraph per element you should probably do as suggested and use a read-only RichTextBox, or <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b36a413f-e57e-4b60-bc08-bcf1f9c8bfd5/" rel="nofollow noreferrer">do what this person did and derive from TextBlock</a> so that the Inlines property can be bound.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload