Open tingjiangcao opened 4 months ago
@tingjiangcao Can you please provide a sample repro project ?
@tingjiangcao您能提出示例项目吗?
Reason: Every time you change the window or add data, the WPF program will recalculate the position and size of each WPF element and then render it. Because you have too much data, the calculation and rendering time will be too long, resulting in lag.
Attach: After testing, virtualization is even worse
<TextBox Foreground="#7B7A7A" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" FontSize="16" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling">
Your Text
</TextBox>
Solution: If you need better performance in TextBox or Richtextbox, please use paging.You can refer to the design pattern of Word and not put all the data in one TextBox. A TextBox is equivalent to a page, which is a fixed size and can store limited data.
There is no reason why WPF should stick to a sub-optimally performing controls. Look at Visual Studio that can open and colorize large amounts of text using WPF, so clearly there is a way.
On the other side, the use case for the existing controls might not be in alignment with the suggested scenario, and there would need to be some compelling justification to redesign them. Others have suggested AvalonEdit which might give you a better performance.
You can refer to the design pattern of Word
People should stop suggesting text boxes are good controls to make text editors, they were never designed for that and Word does not use "text boxes". If you are building a text editor, you are designing a specialized software for which generic purpose controls are rarely a good choice.
A TextBox is equivalent to a page
Not sure where that is coming from. If you switch Word to draft or outline review, you don't get "pages" but still all the text is rendered and editable.
Thank you for your reply, there might be some different undertanding on the needs of op, I'm still researching.
I create a lightweight text editor, but now it is a demo, see https://github.com/lindexi/lindexi_gd/pull/57
Reason: Every time you change the window or add data, the WPF program will recalculate the position and size of each WPF element and then render it. Because you have too much data, the calculation and rendering time will be too long, resulting in lag.
Attach: After testing, virtualization is even worse
<TextBox Foreground="#7B7A7A" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" FontSize="16" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"> Your Text </TextBox>
Solution: If you need better performance in TextBox or Richtextbox, please use paging.You can refer to the design pattern of Word and not put all the data in one TextBox. A TextBox is equivalent to a page, which is a fixed size and can store limited data.
I just got into WPF not long ago.
The genesis of this was that I wanted to get an effect similar to
I had a look at the demo and I think it raises a valid issue, this should perform better.
What the issue does not say is that the textbox is wrapping with VerticalScrollBarVisibility="Auto"
. You can get much better performance if you set this to Visible
.
Description
Richtextbox and textbox set a lot of text, about tens of thousands of words, adjusting width and height lags, content editing lags, is it related to virtualisation.
Reproduction Steps
.
Expected behavior
.
Actual behavior
.
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
No response