void DataGrid_ScrollChanged(object sender, RoutedEventArgs e) { if (null == LogViewModel) { return; } var scrollViewer = FindVisualChild <ScrollViewer>((DependencyObject)sender); if (null == scrollViewer) { return; } if (scrollViewer.ComputedVerticalScrollBarVisibility != Visibility.Visible) { return; } LogViewModel.CapScrollWindow(); scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; }