Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The FlowDocument cannot be shared by several RichTextBox controls directly..</p> <p>So you need to 'detach' that document first...</p> <p>So</p> <pre><code>RTB2.Document = RTB1.Document; </code></pre> <p>wont work and will result in your exception..</p> <pre><code>FlowDocument doc = RTB1.Document; RTB1.Document = new FlowDocument(); //Document cannot be null, so therefor the new FlowDocument instance RTB2.Document = doc; </code></pre> <p>will work like a charm...</p> <p>My code sample:</p> <p>Xaml:</p> <pre><code>&lt;Window x:Class="WpfApplication2.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition /&gt; &lt;ColumnDefinition /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;RichTextBox x:Name="RTB1" /&gt; &lt;RichTextBox x:Name="RTB2" Grid.Column="1" /&gt; &lt;Button x:Name="button" Grid.Row="1" Grid.ColumnSpan="2" Content="click" Click="button_Click" /&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>Code behind..</p> <pre><code>public partial class Window1 : Window { public Window1() { InitializeComponent(); } private void button_Click(object sender, RoutedEventArgs e) { FlowDocument doc = RTB1.Document; RTB1.Document = new FlowDocument(); RTB2.Document = doc; } } </code></pre> <p>Its not the prettiest in the book, but it works...</p> <p>Hope this helps..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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