I have a persistent problem with textboxes in WPF, using .NET 3.5. With a large (5000+ lines) amount of data in a TextBox with wrapping enabled, the window has ridiculously bad performance while being resized.
This only happens with TextWrapping=”Wrap”. Having the text data bound or just setting it programmatically makes no difference.
The code is literally as simple as this:
<TextBox Margin="12,39,337,29" Text="{Binding Output, Mode=OneWay}" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" />
The text is bound to a single string. The bound data is not being changed.
Edit: The data is not being changed while the window is resizing, is what I meant. It will be updated in the future. The TextBox does not need to be editable, but the actual text does need to be selectable. /Edit.
I’ve had a quick play with AvalonEdit, which has the same problem. It seems strange that I can’t find any other threads which describe this issue.
Any advice?
Thanks,
Rich
You could react to the windowResizeStart event and disable wrapping for the text block.
Then wrap just once when the resize completes.
You gain performance but lose some visual flair I guess.