views:

227

answers:

2

Is it possible to use TextBox in "virtual" mode.

I want to supply text on demand, when user scrolls through the document.

A: 

I thought virtual mode was intended to speed up application performance by only getting and rendering data on demand. If the user is scrolling through the document, doesn't that imply that the data is already loaded? Couldn't you databind the TextBox to a property in code-behind and merely set the value of that property while the user is scrolling?

Dave
For example, only first page of data is loaded. When user scrolls down I want text box to ask me for the second page and I'll provide it.
Konstantin Spirin
ah, I see what you mean. like how websites dynamically load content once the first page is viewed by scrolling to the bottom. time to star this question! :)
Dave
+1  A: 

To use the built in virtualization (i.e. VirtualizingStackPanel used by default ListBox) you need to be able to chunk the content into items which can be progressively loaded one at a time as needed (logical scrolling). To do this for arbitrary large text would involve a lot of pre-processing to calculate line wrapping and break the text up into lines or groups of lines. Once you do that you would need to use a container derived from ItemsControl instead of a single TextBox. Do you have a requirement to have editable text?

John Bowen
Not editable but being able to select piece of text and do Ctrl+C would be good.
Konstantin Spirin