This project has moved and is read-only. For the latest updates, please go here.

"Blank" text in RichTextBox

Apr 24, 2012 at 10:28 AM

Hello,

I'm using the RichTextBox to edit a description in my C# WPF application

<toolkit:RichTextBox
x:Name="TbDesc"
Grid.Row="2"
Margin="3"
Text="{Binding Project.Description, UpdateSourceTrigger=PropertyChanged}"
AcceptsReturn="True"
AcceptsTab="True"
VerticalScrollBarVisibility="Auto">
<toolkit:RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0" />
</Style>
</toolkit:RichTextBox.Resources>
<toolkit:RichTextBox.TextFormatter>
<toolkit:XamlFormatter />
</toolkit:RichTextBox.TextFormatter>
</toolkit:RichTextBox>

The problem is, that if the user clears the RichTextBox the Project.Description (binding), still contains all the Xaml for formatting (XamlFormatter) the text.

All this useless will be saved in the database.

How can I determine if there is no "text" in the RichTextBox?

May 7, 2012 at 3:18 PM

I have tried different methods of parsing the xaml using Regular Expressions, to determine if the content is empty.

This doesn't work very well.

An "integrated" solution would be much better!