Does anyone know of a reliable approach for scrolling a WPF DataGrid (.NET 4) to the last row programmatically?
I\'m aware of ScrollIntoView(I
For anyone with this problem, the following seems to do the trick:
var scrollerViewer = GetScrollViewer();
if (scrollerViewer != null) scrollerViewer.ScrollToEnd();
...
ScrollViewer GetScrollViewer()
{
if (VisualTreeHelper.GetChildrenCount (this) == 0) return null;
var x = VisualTreeHelper.GetChild (this, 0);
if (x == null) return null;
if (VisualTreeHelper.GetChildrenCount (x) == 0) return null;
return VisualTreeHelper.GetChild (x, 0) as ScrollViewer;
}