Hello,
I can not continue get selecting text after apply color for selection text.
richTextBox1.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Blue));
richTextBox1.Selection.ApplyPropertyValue(TextElement.FontWeightProperty,
FontWeights.Bold);
This is my code:
//Content of richTextBox1: "Change color for selecting text" // Get text1 = "color" int startIndex = 7; int Length = 5; TextPointer start1 = richTextBox1.ContentStart.GetPositionAtOffset(startIndex + 2, LogicalDirection.Forward); TextPointer end1 = richTextBox1.ContentStart.GetPositionAtOffset(startIndex + 2 + Length, LogicalDirection.Forward); richTextBox1.Selection.Select(start1, end1); string text1 = richTextBox1.Selection.Text;
//text1="color" ( it is right :) ) // Apply color for text1 richTextBox1.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(Colors.Blue)); richTextBox1.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold); //Continue: get text2="selecting" startIndex = 17; Length = 9; TextPointer start2= richTextBox1.ContentStart.GetPositionAtOffset(startIndex + 2, LogicalDirection.Forward); TextPointer end2 = richTextBox1.ContentStart.GetPositionAtOffset(startIndex + 2 + Length, LogicalDirection.Forward); richTextBox1.Selection.Select(start2, end2); string text2 = richTextBox1.Selection.Text; //text2 is "for selec" (It it not right :(, I want to get "selecting" :(()
Can you help me?
Thank you.