0

I have a ScrollViewer with a static height that houses a collection of ListBoxes. Whenever the ListBoxes do not trigger the appearance of the ScrollBar, I'd like to populate them with fake data (for visual purposes).

As I add elements to the list (in my ViewModel), the ScrollableHeight/ExtentHeight does not change; I'm guessing that it is because the front end is not updating. Is there a way for me to force the UI to update before I add another listbox item? Right now, I get stuck in a loop until my application crashes.

Thank you.

  • 1
    Write a method that checks to see if you need to add one. If it doesn't, it returns. If it does, it adds one, then schedules itself to execute again later using the Dispatcher, telling it to run you when the application is idle. The dispatcher will then run your method again, and the process repeats until you don't want to add more. Or, just measure the size of one of the things you want to add, calculate how much room you need to take up, do some math, and add that number. –  Feb 01 '17 at 21:01
  • Hi Will, thanks for your answer. I tried it, but the speed of execution is quite slow, Whenever I load the app, I can see the Scrollviewer progressively fill up. Do you know if there's a way to get around this? – Rufino Ricardo Ansara Feb 01 '17 at 21:28
  • http://stackoverflow.com/questions/8128670/force-redraw-before-long-running-operations – Pouya Abadi Feb 01 '17 at 23:17
  • 1
    Can you post some example code, hard to give advice from your description only? – Kelly Feb 02 '17 at 01:29
  • What is the break condition of your loop? – Michael Fayad Feb 01 '19 at 21:58

0 Answers0