Binding Text in RichTextBox

Nov 21, 2011 at 1:41 PM



I'm trying to use the RichTextBox in a project of mine. The problem however, is, that I can't figure out how to databind the Text-property.

The documentation explains the binding like this

<toolkit:RichTextBox x:Name="_richTextBox" Grid.Row="1" Margin="10" BorderBrush="Gray" Padding="10"
                                          Text="{Binding Notes}" 
                                          ScrollViewer.VerticalScrollBarVisibility="Auto" />

I have bound the TextBox to a property called Description of type String. When I try to get the value of Description it is just null. How can this be?

Nov 22, 2011 at 1:47 PM


I used the following for my implementation.  Maybe this will help.  I used a XAML formatter in my code, but you may have a different requirement and need to use another one or roll your own.

<tk:RichTextBox x:Name="RTB" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="2" Margin="4" BorderBrush="Transparent" Padding="8" BorderThickness="0"  IsEnabled="{Binding Path=CanEdit}"
                            Text="{Binding Path=CurrNote.Content, UpdateSourceTrigger=PropertyChanged}" ScrollViewer.VerticalScrollBarVisibility="Auto" 
                                FontFamily="Segoe UI" FontSize="12" FontWeight="Normal" AcceptsTab="True" AcceptsReturn="True" IsReadOnly="{Binding Path=CurrNote.IsNotAuthor}" IsUndoEnabled="True"
                        <Style TargetType="{x:Type Paragraph}">
                            <Setter Property="Margin" Value="0"/>


Nov 28, 2011 at 2:15 PM

Have you solved your issue?