Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
Maintain scroll position after rebinding
posted

Hi,

I have fairly straightforward code that refreshes the data in the grid. What I'd like to do is maintain the scrolling position.

Here's what I have:

double vOffsetBackup = myGrid.ScrollInfo.VerticalOffset;
myGrid.DataSource = newData;
myGrid.ScrollInfo.SetVerticalOffset(vOffsetBackup);

This, however, doesn't seem to work. The only way I could get it to work is by invoking SetVerticalOffset with a dispatcher, but then I get this flicker effect where the user can see the scroll bar moving.

Any suggestions on how to resolve this?