diff --git a/src/UI/Blame.xaml.cs b/src/UI/Blame.xaml.cs index d9df77aa..11630441 100644 --- a/src/UI/Blame.xaml.cs +++ b/src/UI/Blame.xaml.cs @@ -171,7 +171,7 @@ namespace SourceGit.UI { var minWidth = total - offset; var scroller = GetVisualChild(blame); - if (scroller.ComputedVerticalScrollBarVisibility == Visibility.Visible) minWidth -= 8; + if (scroller != null && scroller.ComputedVerticalScrollBarVisibility == Visibility.Visible) minWidth -= 8; blame.Columns[1].MinWidth = minWidth; blame.Columns[1].Width = DataGridLength.SizeToCells; diff --git a/src/UI/DiffViewer.xaml.cs b/src/UI/DiffViewer.xaml.cs index faa1f240..287e20a0 100644 --- a/src/UI/DiffViewer.xaml.cs +++ b/src/UI/DiffViewer.xaml.cs @@ -466,12 +466,16 @@ namespace SourceGit.UI { if (e.VerticalChange != 0) { foreach (var editor in editors) { var scroller = GetVisualChild(editor); - if (scroller.VerticalOffset != e.VerticalOffset) scroller.ScrollToVerticalOffset(e.VerticalOffset); + if (scroller != null && scroller.VerticalOffset != e.VerticalOffset) { + scroller.ScrollToVerticalOffset(e.VerticalOffset); + } } } else { foreach (var editor in editors) { var scroller = GetVisualChild(editor); - if (scroller.HorizontalOffset != e.HorizontalOffset) scroller.ScrollToHorizontalOffset(e.HorizontalOffset); + if (scroller != null && scroller.HorizontalOffset != e.HorizontalOffset) { + scroller.ScrollToHorizontalOffset(e.HorizontalOffset); + } } } } @@ -486,6 +490,8 @@ namespace SourceGit.UI { var grid = editors[0]; var scroller = GetVisualChild(grid); + if (scroller == null) return; + var firstVisible = (int)scroller.VerticalOffset; var firstModeEnded = false; var first = grid.Items[firstVisible] as ChangeBlock; @@ -512,6 +518,8 @@ namespace SourceGit.UI { var grid = editors[0]; var scroller = GetVisualChild(grid); + if (scroller == null) return; + var firstVisible = (int)scroller.VerticalOffset; var firstModeEnded = false; var first = grid.Items[firstVisible] as ChangeBlock;