<RichTextBox AcceptsTab="True" ForceCursor="True" IsDocumentEnabled="True" TextChanged="ContentChanged" Name="TextContent"/>
In C# file i am not able to get Text property of Rich Textbox.
I am trying to get this like;
TextContent.Text= "hello"
But it is giving compile time error.
'System.Windows.Controls.RichTextBox' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'System.Windows.Controls.RichTextBox' could be found (are you missing a using directive or an assembly reference?)
Please suggest me.
Best Answer
Generally, you need to work with
Blocks
property. But, if you are usingFlowDocument
for representingRichTextBox
content, then you can access text withDocument
property.For example, writing content:
XAML:
Code:
To read content you simply access
Document
property:If you need just to take text, you have more simple way -
TextRange
class. Next code will retrieve all text content: