This is a migrated thread and some comments may be shown as answers.

Caching GridRow instances

1 Answer 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eugen Wiens
Top achievements
Rank 1
Eugen Wiens asked on 26 Jul 2012, 06:49 AM
Hello,

i have the following szenario:

On the left side of the screen I have a list of Employees. On the right side is a GridView with a variable number of rows (lets say 10 to 100).

When I select an employee in the list, the GridView shows employee specific data in the GridView. When I select a different employee the following happens:
  1. The ItemsSource list of the GridView is cleared
  2. The ItemsSource list is filled with new data specific to the now selected employee

The problem: To switch from one employee to another takes to long time because the creation of the GridRows etc. takes to long. With long I mean for 50 Rows about 500ms on an high end machine.

My assumption is when 1. happens all GridRow instances are destroyed and recreated again in 2.

So here are my questions:

1. Is my assumption correct?
2. If assumption not correct: what else could be the problem?
3. If assumption correct: do you have a suggestion, how i could solve that issue? Is there an easy way to prevent the GridRow instances from disposure? An easy way to cache that instances?

Thanks for your help,

Eugen

1 Answer, 1 is accepted

Sort by
0
Eugen Wiens
Top achievements
Rank 1
answered on 26 Jul 2012, 08:52 AM
Hey Again,

i solved this issue, DeferRefresh() is the key.

usage:

make the change of the ItemsSource collection in the following using statement:

using (GridName.DeferRefresh())
{
    // edit your ItemsSource collection here (clear(), add(), remove())
    // refresh will be applied only once...
}

this causes an unbelievable performance boost

Eugen
Tags
GridView
Asked by
Eugen Wiens
Top achievements
Rank 1
Answers by
Eugen Wiens
Top achievements
Rank 1
Share this question
or