string RTF = @"{\rtf1\ansi\deff0 " + @"{\colortbl;\red0\green0\blue0;\red255\green0\blue0;} "+ @"line1 \line "+ @"\cf2 "+ @"line 2 \line "+ @"\cf1 "+ @"line 3 "+ @"}"; MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(RTF)); TextRange range = new TextRange(demo.Document.ContentStart, demo.Document.ContentEnd); range.Load(stream, DataFormats.Rtf);
<RichTextBox HorizontalAlignment="Left" Height="116" Margin="37,266,0,0" Grid.Row="1" x:Name="demo" VerticalAlignment="Top" Width="381"> </RichTextBox>
private void RichTextBox_TextChanged(object sender, TextChangedEventArgs e){ rtb.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Red);}
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)