DataGrid Exception After Calling ScrollIntoView

Mar 12, 2009 at 10:16 PM
Hello Codeplex,

I have discovered a bug that occurs after I call ScrollIntoView and it throws a NullReferenceException. 

Here is some background on my situation:

I have a generic user control containing a datagrid and functionality for editing, inserting and deleting items (rows in the datagrid).
I want to be able to use tab to get through controls so I have a style with Cell.IsTabStop = False.
But I want to be able to tab into the data grid. What I have done is added a handler for when the selected index property changes.
When the DataGrid.SelectedIndex property changes I focus on the cell in the first column and selected row.

This is done using the GetCell(row, column) method that has been floating around here (

When calling ScrollIntoView when this change is made, I sometimes get a null reference exception, which I geuss could be expected if the list was changing. I have guard clauses for the row and columns to ensure that they lie in the index.

But after I catch this exception, the DataGridCellsPresenter class this an exception at line 98  Debug.Assert(dataGridOwner != null, "We shouldn't be syncing properties if we don't have a valid DataGrid owner");

System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.

Apr 30, 2009 at 4:54 AM
I am getting errors using scrollintoview that completely puts my application into a bad state.  I would get the null reference exception stated above as well.  I have not had time to dig deeply into this as I am deep into a production release today (and we have other issues to work through first).  We had to remove the scrollintoview call...

What release are you using?
Oct 1, 2009 at 12:04 PM

Sorry to bump an old post, but I'm experiencing this problem now..

Did you find any solution to it?

Oct 2, 2009 at 3:35 AM

Hi all,

You can try to call UpdateLayout() before calling ScrollIntoView().



Oct 2, 2009 at 6:38 AM


That solved my problem:)