Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to load large text files in AvalonEdit control inside custom WPF C# project
    primarykey
    data
    text
    <p>We are developing a .Net 4.0 C# WPF Line-of-business app and need to show (readonly) large text files to the user. <code>TextBlock</code> as stated in SO is not an option and tried the suggested AvalonEdit control. Running the AvalonEdit.Sample standalone app can load a 4MB file with 8k lines in less than a second, but when embedding the AvalonEdit <code>TextEditor</code> into our WPF app spends 20 seconds, almost the same as the previous <code>TextBlock</code>.</p> <p>The UI is quite complex, with a splitter for tree-menu and forms. The form has several splitters to create resizable zones and one of them contains a tab control. One of the tab items has the <code>TextEditor</code> from AvalonEdit.</p> <p>XAML</p> <pre><code>&lt;avalonEdit:TextEditor Name="Tbx" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" /&gt; </code></pre> <p>CS</p> <pre><code>public void ShowFile(string path) { Tbx.Text = string.Empty; ThreadPool.QueueUserWorkItem(o =&gt; { var lines = File.ReadAllLines(path).Join("\n"); Dispatcher.BeginInvoke(() =&gt; Tbx.Text = lineas); }); } </code></pre> <p>When loading the file, my laptop i7 4-core CPU usage is 33%.</p> <p>Any suggestion about the different behaviour of AvalonEdit <code>TextEditor</code> as standalone app and within a custom WPF app?</p> <p>How to load large files (10MB, 10k lines) with <code>TextEditor</code>?</p> <p><strong>UPDATE:</strong></p> <p>The Visual Tree:</p> <p><img src="https://i.stack.imgur.com/NyEGQ.png" alt="Visual tree"></p> <p>The properties of the <code>TextEditor</code>:</p> <p><img src="https://i.stack.imgur.com/tqott.png" alt="TextEditor properties"></p> <p>I removed a ScrollViewer that host the <code>TextEditor</code> as pointed, but same poor performance is achieved.</p> <p><strong>UPDATE 2:</strong> I moved the <code>TextEditor</code> to a new window to reduce the layout but still get poor performance.</p> <p>The new, simplified Visual Tree:</p> <p><img src="https://i.stack.imgur.com/cFKr8.png" alt="Visual Tree 2"></p> <p><code>Grid</code> column and row definition is <code>*</code>.</p> <p>The properties of the <code>TextEditor</code>:</p> <p><img src="https://i.stack.imgur.com/udKUa.png" alt="TextEditor properties"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload