views:

61

answers:

1

I need to show a really huge amount of text data in my piece of code - first i tried to use TextBox (and of course it was too slow in rendering). Now i'm using FlowDocumentView - and its awesome but recently i have had another request - text shouldnt be hyphenated. Well actually it is not (

       document.IsHyphenationEnabled = false;

) but i still dont see my precious horizontal scroll bar. if i magnify scale text is ... hyphenated. alt text

    public string TextToShow
    {
        set
        {
            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(value);


            FlowDocument document = new FlowDocument(paragraph);
            document.IsHyphenationEnabled = false;

            flowReader.Document = document;
            flowReader.IsScrollViewEnabled = true;
            flowReader.ViewingMode = FlowDocumentReaderViewingMode.Scroll;
            flowReader.IsPrintEnabled = true;
            flowReader.IsPageViewEnabled = false;
            flowReader.IsTwoPageViewEnabled = false;
        }
    }

That's how i create FlowDocument - and here comes part of my wpf-control:

     <FlowDocumentReader Name="flowReader" Margin="2 2 2 2" Grid.Row="0"/>

Nothing criminal =))

I'd like to know how to tame this beast - googled nothing helpful. Or you have some alternative way to show megabytes of text, or textbox have some virtualization features which i need just to enable. Anyway i'll be happy to hear your response!

A: 

It's really wrapping not hyphenation. And one can overcome this by setting FlowDocument.PageWidth to reasonable value, the only question was how to determine this value. Omer suggested this recipe msdn.itags.org/visual-studio/36912/ but i dont like using TextBlock as an measuring instrument for text. Much better way:

            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(value);


            FormattedText text = new FormattedText(value, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(paragraph.FontFamily, paragraph.FontStyle, paragraph.FontWeight, paragraph.FontStretch), paragraph.FontSize, Brushes.Black );

            FlowDocument document = new FlowDocument(paragraph);
            document.PageWidth = text.Width*1.5;
            document.IsHyphenationEnabled = false;

Omer - thanks for the direction.

ProfyTroll