WPF Toolkit: how to scroll datagrid to show selected item from code behind?
- by Akash Kava
I tried following, all of following fails on function ScrollIntoView and gives NullReferenceException.
// doesnt work
grid.SelectedItem = sItem;
grid.ScrollIntoView(sItem);
// doesnt work
grid.SelectedItem = sItem;
grid.Focus();
grid.CurrentColumn = grid.Columns[0];
grid.UpdateLayout();
grid.ScrollIntoView(sItem,grid.Columns[0]);
// doesnt work
grid.SelectedItem = sItem;
grid.UpdateLayout();
grid.ScrollIntoView(sItem);
The problem is, when I select row from codebehind, selection is not visible its somewhere down in bottom, unless user scrolls he feels that selection has vanished. I need to scroll datagrid to the point user can see the selection.
I also tried "BringIntoView" as well but no luck.