1

I have an ItemsControl that is bound to a collection of Tests. Every Test contains a LogFile(the log files are huge and takes a long time to load). Every log file is displayed as a TextBox. Only one log file is visible most of the time.

Is there a way to determine if a TextBox is currently visible on the screen so I can load the corresponding LogFiles only if needed? I already use a ScrollViewer with my ItemsControl to display the scrollbars.

Michael
  • 1,557
  • 2
  • 18
  • 38
  • 1
    So it is just automatically loading the log file if its in view? That doesn't sounds like a good idea. Why not make the user select the file or something? – Kcvin Mar 28 '14 at 16:26
  • Well, right now each TextBox is contained in an Expander. The "Expanded" property depends of the result of the Test. Log files are loaded only if the Expander is "Expanded". However, too many LogFile can still be loaded and almost every time, only one is visible on the screen. Unfortunately I cannot change that behavior and the user needs to be able to scroll among the LogFiles and the logs needs to be loaded on demand. – Michael Mar 28 '14 at 16:38
  • 1
    The user is crazy. Automatically loading files that don't necessarily need to be loaded will only bog down your application and use resources that aren't. You also need to determine if you need to unload the files and free up resources don't forget. Depending on the RAM available on the users machine, this application could get ugly. But anyways, does [this](http://stackoverflow.com/questions/2492214/wpf-itemscontrol-how-to-know-when-the-items-finished-loading-so-that-i-can-fo) help you? – Kcvin Mar 28 '14 at 16:54
  • Do you know if the performance issue is caused from loading the log files, or loading the UI showing the log files? If its the former, there are ways you can manage this in the code behind, such as lazy loading the property or loading them concurrently on a background thread. If its the later (or if you're using lazy loading properties), you may want to look into [Virtualizing your ItemsControl](http://stackoverflow.com/q/2783845/302677). I suspect your issue is related to the UI, in which case virtualizing your ItemsControl should help. – Rachel Mar 28 '14 at 18:56

0 Answers0