Replies: 0 comments 9 replies
-
I want to climb atop a mountain and scream, "I need this too". I built a UWP rest api client, and while it's mostly stable, the one thing that can reliably crash it is when the user pings an endpoint that returns over thousands of lines of json/xml. That breaks the textbox I use to display the response string and I'm livid that I cannot do anything about this since it's a platform limitation. I have been searching for months on a virtualized textbox but no luck. I would love to see work on this happen. Edit: I don't have much experience building a control from scratch, but if someone would like to try building this, I will contribute wherever I can. |
Beta Was this translation helpful? Give feedback.
-
@dpaulino I'm exploring using Win2d to create my own text block which I've never used so I don't know all the in's and out's with it. As a prototype I created a List with 1,000,000 elements, a CanvasControl and a ScrollBar. When the ScrollBar "Scroll" event fired I called "Invalidate" on the CanvasControl which fires it's "Draw" method. If you were creating TextBlocks with Runs you'd just replace those with DrawText calls in place of those and I think it would be straightforward. In the Draw method I used a Linq query to get the next 50 records based off of the ScrollBar position. The result was I put a million lines onto the screen and it scrolled without a hiccup all the way up and down the list (it has the capability to show those lines, it only renders how many I tell it at a time). My CPU spiked at 6% when I was dragging the scroll bar up and down. When I was going line by line or with page up and page down it was about 2%-3%. I didn't do any parsing however, it was just straight text (I'm parsing ANSI colors from a TCP/IP stream so my use case is pretty simple). I think I maybe able to do something with this. My prototype doesn't do these things I would need to research and trial and error with: 1.) It doesn't have any concept of how many lines the screen is capable of displaying. I set the window size and only drew 50 at a time which I knew would fit. I used a set font size and tried to calculate the vertical position in a way that I'm not sure would translate well to other fonts or DPI's, I would need to learn more about how to handle that. I think what I'll try to do is get something that works for me and then try to abstract that into something that's re-usable. I'll keep you posted if I make decent progress on it. |
Beta Was this translation helpful? Give feedback.
-
@blakepell sounds good. If you're also willing to try, there's a powerful WPF text editor control called Avalon Edit. I wonder if we could fork it and make it run on UWP? https://github.com/icsharpcode/AvalonEdit |
Beta Was this translation helpful? Give feedback.
-
Looks like a couple people tried to bring it to UWP three years ago, but they abandoned it almost as soon as they started. https://github.com/coderobin/AvalonEdit |
Beta Was this translation helpful? Give feedback.
-
I saw that also. :D Hehe. The Monaco editor was something I looked at also (that's the editor behind VS Code). There's a wrapper control to use it in UWP but I think it also has some performance issues with too much content. |
Beta Was this translation helpful? Give feedback.
-
To show you what I was playing with and how little code it was initially. This was in a blank uwp app with Win2d added via NuGet. You can get a feel for how fast it scrolls and renders.
|
Beta Was this translation helpful? Give feedback.
-
There's a uservoice request for this feature to be built by the platform team: https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/37090696-virtualized-richeditbox |
Beta Was this translation helpful? Give feedback.
-
I've spent some time thinking of who would be best able to tackle the creation of this control from a first-party standpoint, and I think the owners of the WinUI library would be best (https://github.com/Microsoft/microsoft-ui-xaml). I may try to submit a feature proposal for this virtualized textbox/richeditbox control when I get some free time. For reference, here is their feature proposal process: https://github.com/Microsoft/microsoft-ui-xaml/blob/master/docs/feature_proposal_process.md |
Beta Was this translation helpful? Give feedback.
-
With .NET Core 3 I've decided to migrate my project from UWP to WPF, less road blocks and red tape. @dpaulino I'm actually going to use the project you mentioned, Avalon Edit, which now has .NET Core 3 support (that editor is rock solid in everything I've thrown at it). In a very minimal amount of code I was able to get it render all of the ANSI sequences I need to support. I put half a million lines into it with millions of changing color sequences without so much as a hiccup on the performance front (scrolls from top to bottom and left to write like a champ). Avalon Edit is so versatile and can be used for so many use cases I think something like it would be wonderful in this project. |
Beta Was this translation helpful? Give feedback.
-
I'm submitting a feature request for a Virtualized RichEditBox
Uservoice: https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/37090696-virtualized-richeditbox
I've had difficulty located examples on how to display and/or edit large files in UWP. It's my understanding the solution to this would be a VirtualizedRichEditBox. The current RichEditBox (or RichTextBlock, or TextBlock) are not virtualized and become incredibly slow with even moderate amounts of data. In my setup, greater than 4,000 lines and the UI because incredibly laggy. The only examples of this I can locate are vended products. I have worked around this issue by using a ListView but it is less than ideal because you lose the ability to do things such as select over lines that you would have in a traditional text box or text block.
Beta Was this translation helpful? Give feedback.
All reactions