0
votes

We have a control that displays a large amount of data using a number of controls of varying sizes and complexities. Due to the large amount of controls that need to be layed out, there can be a very noticable delay.

We know the delay comes from the Measure/Arrange functions as we have a test class that derrives from a stackpanel that overrrides them with some timing code.

We dont want to use virtualization due to the side affects of the scrollbars constantly changing their range, and we dont want to hide the data under expanders or any other collapsing controls as the client has requested that we display it all in one long list. However, they want to know that the control is actually doing something when the delay occurs, some kind of progress status.

So my question is - Is there somehow a way of creating a control that displays a loading animation as an adorner or something until its content has actually been laid out? I appreciate this probably isn't possible as the arranging/measuring is also done on the UI thread.

1
Did you try priority binding? That is how I do this but I also embrace virtualiztion.paparazzo
Use Virtualization. Forget the scrollbars. Otherwise you need to Create the BusyIndicator in a Separate ThreadFederico Berasategui

1 Answers

0
votes

In my experience, I would unfortunately have to say that the answer is no. I have spent a long time trying to find a solution to a very similar problem.

The crux of the problem is that any work populating UI controls with data must be performed on the UI thread. All of the data in my application is fetched asynchronously to 'free up the UI'... while this is happening in background threads, the UI thread is free to display an animated loading image. However, as soon as the data has arrived and begins to populate the UI controls, the loading animation freezes as you might expect.

I have even tried using a .gif image as I thought that it wouldn't need any time on the UI thread, but unfortunately, WPF does NOT support .gif animations. I designed a class to animate each frame of the .gif file in turn and tried it again, but now the (manual) .gif animation did use UI thread time and therefore froze as the controls were being populated.

So the options that you are left with are these:

  1. display an animated loading image/shape that will freeze when data is populating controls or
  2. display a non-animated loading image/shape

I went for the animated version that freezes at the last moment as data is populated.