Poul K. Sørensen
Poul K. Sørensen

Reputation: 17530

What is the easiest way to show a log file in WPF

I have a log file, in a memorystream, that can easily be read to a string. But I am not sure how i display this file best in WPF. I tried a TextBlock and binded it to the text property. But the application just dies when loading the file.

Are there other controls that will be good to show a log file within. There are no parameters, its just one record pr line of text that i would like to show and easy scroll within.

Every now and then a new line is added to the log and i need to update the view.

Solution

Using AvalonEdit , TextEditor loads fast and works nicely.

Upvotes: 1

Views: 2221

Answers (1)

Patrick
Patrick

Reputation: 284

I'd make a ListView with the ItemsSource a list of the Records you have in your logfile. When you use an ObservableCollection as ItemsSource, then you can easily update your view by adding the new record to the ObservableCollection.

Edit: With 100000 records this way will take some time to initialize due to creating a TextBlockper record. You could try the TextBox control. Maybe this will work for your case. Binding the Text Property and add the new records to the bound string.

Or maybe this helps you.

Upvotes: 3

Related Questions