I am having the same issue as the one above. The scenario is described below:
The grid ItemSource property is getting bound to a structure which is something like given below
Here each column has a CellTemplate which contains a custom control.
The DetailsGridItemView control uses the Context property to render itself correctly.
The correct behavior for the grid is to bind each row to an instance of DetailsGridRowModel. When I disable the row and column virtualization everything works fine.
However, when I don't have them set explicitly or I enable them explicitly the followng behavior starts happening.
- The grid starts to re-bind data to a control that is no-longer visible and hence might be re-used.
- The data that gets picked up for binding is not in the correct order. So the order of items gets lost on sort and that causes a lot of problems and confusion.
Let me illustrate. Say the number of rows visible is 5 and the data for each row is the following list. Lets also assume that the == bars represent the top and bottom edges of the grid control.
let's say my list is containing the following data
This is what the user sees then the grid first renders.
==================
==================
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
Now lets assume that the user scolls to the bottom. The user sees the following.
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
===================
===================
However now when the user scrolls up, the grid does not pick up the items in the list in the correct order. So this is what the user might see (I say might since what gets picked up and bound doesn't seem to be deterministic.)
==================
==================
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
If you notice in the illustration above, I have tried to show that the list shown to the user is not fixed at all. It actually changes and depends on various things which change the timing of the the events firing inside such as
- The user stop scrolling and removed the mouse from the scrollbar when he reached at the bottom (as in mousebuttonup event fired or not) and then scrolled up again.
- OR The user scrolled to the bottom and with mouse button still down scrolled to the top slowly or very quickly, etc.
In fact sometimes if the user now scrolls down this is what he might see which absolutly confuses the user.
- ? <can't see this right now>
- ? <can't see this right now>
- ? <can't see this right now>
==================
==================
- ? <can't see this right now>
- ? <can't see this right now>
In the real solution I have about 60 rows and 30 are visible on the grid at any time.