Get row count from Silverlight RichTextBox?

Is there a way to get the number of rows from Silverlight RichTextBox? I tried reading tags <Run>, but that doesn't seem very accurate. The text in RichTextBoxwill be different every time, so I need a good reliable way to count the number of lines of text when the user finishes typing.

Does anyone know how to do this?

+3
source share
1 answer

Well, I also had this code with start tags (I did not write it, and I can’t remember where it came from, so I won’t be grateful for it). Is that not so?

int blockCount = 0; 
int lineCount = 0; 
foreach (Block b in myRTB.Blocks) 
{ 
    if (b is Paragraph) 
    { 
        p = new Paragraph(); 
        p = b as Paragraph; 
        foreach (Run run in p.Inlines) 
        { 
            lineCount++; 
        } 
        blockCount++; 
    } 
} 
+1
source

Source: https://habr.com/ru/post/1794803/


All Articles