Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

RichTextBox slows down the entire UI

$
0
0

I have an application which opens multiple text files in different tabs. I use RichTextBox while processing this data in my application. However, loading large text files(10MB) slows the entire UI. Is there a way to solve this problem? I am thinking of lazy loading the file, so when the user presses the scroll button, later part of the file has to be loaded. Is there a place where I can start with this approach? Please help me I am pretty new to WPF and C# programming.

RichTextBox mcRTB = new RichTextBox(); rtbList.Add(mcRTB); mcRTB.SelectionChanged += mcRTB_SelectionChanged; TabItem tab = new TabItem(); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(System.IO.File.ReadAllText(filePath)); FlowDocument document = new FlowDocument(paragraph); mcRTB.Document = document; StringBuilder dataContent = new StringBuilder();

//this statement takes few seconds, need to find alternatives dataContent.Append(new TextRange(mcRTB.Document.ContentStart, mcRTB.Document.ContentEnd).Text); mcRTB.TextChanged += new System.Windows.Controls.TextChangedEventHandler(SegFileDataContentChanged); tab.Content = mcRTB;




Viewing all articles
Browse latest Browse all 18858

Trending Articles