WPF Toolkit: how to scroll datagrid to show selected item from code behind?
Posted
by Akash Kava
on Stack Overflow
See other posts from Stack Overflow
or by Akash Kava
Published on 2009-12-31T10:37:52Z
Indexed on
2010/04/13
18:33 UTC
Read the original article
Hit count: 1002
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.
© Stack Overflow or respective owner