xamlwindows-runtimewinrt-xamlwindows-8.1richtextblock

Count symbols in RichTextBlock WinRT


I have a RichTextBlock with some text.I dont want use vertical and horizontal scrolls. If I add a large text, some text is hiding. How can I get hidden text or how can I get current not hided text? Size of my RichTextBlock set dynamically. TextWrapping="Wrap" is set.

<RichTextBlock x:Name="BookViewer" HorizontalAlignment="Left" Height="525" Margin="63,0,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="1246" TextAlignment="Justify" > </RichTextBlock> 

codebehind:

private void SetText(string value) { BookViewer.Blocks.Clear(); Run myRun = new Run(); myRun.Text = value; Paragraph myParagraph = new Paragraph(); myParagraph.Inlines.Add(myRun); BookViewer.Blocks.Add(myParagraph); } 

Solution

  • I wonder if RichTextBlockOverflow could somehow help you there. Otherwise - you'd need to keep adding more text and see when it starts overflowing by calling Measure()+Arrange() and checking ActualWidth/ActualHeight. If that sounds clunky - you could use DirectWrite instead, which might be faster and better suited to handling custom layouts.