This may be a very basic question for some but I am rather stuck and haven't been able to find a direct answer from stack or google. If anyone could help that would be great, Was wondering How do I bind a RichTextbox Text to a string.
So I have a variable on my MVVM called Notes and would like to bind it to the Radrichtextbox.
I was thinking something on the lines of this:
<RichTextBox x:Name="RichTextBox1" Text="{Binding Notes}" />
But there's no Text Methods :S
You can use RichTextBox(link) from Extended WPF Toolkit.
Example:
<toolkit:RichTextBox x:Name="_richTextBox" Grid.Row="1" Margin="10" BorderBrush="Gray" Padding="10"
Text="{Binding Notes}"
ScrollViewer.VerticalScrollBarVisibility="Auto" />
where toolkit is namespace to Extended WPF Toolkit library:
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
Installation guide:
Instructions for using the Extended WPF Toolkit binaries (link):
Or you can install this library by NuGet (link):
PM> Install-Package Extended.Wpf.Toolkit
Oh yeah. Try this
<RichTextBox>
<RichTextBox.Document>
<FlowDocument>
<Paragraph>
<Run Text="{Binding Path=Notes}" />
</Paragraph>
</FlowDocument>
</RichTextBox.Document>
</RichTextBox>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With