Using a RunRange is a very easy way to navigate the parts of a TextBlock. However, There seems to be very little one can actually use it for (ToString() and GetProperties() functions). I have a desired to be able to utilize FindText() on ONLY certain sections (i.e. runs) of a TextBlock. It *seems* it is not possible to obtain the start and ending caret of the RunCR when using a "for each..." construct on a RunRange. IF only it were possible...
RunRange runRange(*textBlock); for each(RunCR thisRun in runRange) { // wish I could get start and end carets for "thisRun" }
What I've tried is to create a TextBlock that represents the text of the "thisRun". However, when the temporary textBlock is made, all character encodings are lost when the TextBlock is created:
TextBlockPtr tempTextBlock = textEdit->GetTextPart(eeh, *textPartId); tempTextBlock->Remove(*textBlock->CreateStartCaret(), *textBlock->CreateEndCaret()); tempTextBlock->AppendText(thisRun.ToString().c_str()); // We lose all encodings....
If there is a way to get Carets for the current RunCR please inform me.
Bruce