Search code examples
c#wpfdatagridrowdetails

Datagrid slow when multiple row details have been expanded


So i have a datagrid, the contents of which are all populated from multiple web requests. The rowdetails, when expanded, also send multiple web requests to populate more information.

In the row details, there is a Listview, a listbox, a few layout elements, and some textblocks.

The datagrid scrolls fast after the initial data is added, but if you expand 4-5 row details, suddenly the scrolling is choppy to the point it is almost non existent.

Is this a known issue?

Can i reuse the same visual rowdetails element for each item? it is only shown when selected and all the data retrieved is cached so it wouldn't need to be reloaded on an element that has already been viewed

Rows are not expanded more than one at a time... The row details are only shown when an item is selected, and you can only select one at a time. The problem is that after you select a few different items, and the row detail visual objects are generated, it slows down.


Solution

  • I found the problem.

    In the row details was this item:

    <Image Source="{Binding Path=PreviewImageUrl, TargetNullValue=Collapsed}" />
    

    PreviewImageUrl was null and for each row details item that was created/expanded, it would throw (and suppress) an Image converter exception while scrolling. That exception suppression is what was slowing the scrolling (as after expanding 10 row details, it would throw 10 exceptions on each scroll event). As to why this happens I am still puzzled but at least I now know what to watch for!