From 24dedb39e9a052eb023f977f10ab4329d578df3b Mon Sep 17 00:00:00 2001
From: "harald.martini@student.tugraz.at" <harald.martini@student.tugraz.at>
Date: Tue, 22 Jun 2021 10:19:15 +0200
Subject: [PATCH] Fixed error in autoscrollbehavior when deleting an element
 from the source collection

---
 VECTO3GUI2020/Behaviours/AutoScrollDataGridBehaviour.cs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/VECTO3GUI2020/Behaviours/AutoScrollDataGridBehaviour.cs b/VECTO3GUI2020/Behaviours/AutoScrollDataGridBehaviour.cs
index 3e283eed3c..eb319de1bd 100644
--- a/VECTO3GUI2020/Behaviours/AutoScrollDataGridBehaviour.cs
+++ b/VECTO3GUI2020/Behaviours/AutoScrollDataGridBehaviour.cs
@@ -43,6 +43,9 @@ namespace VECTO3GUI2020.Behaviours
 		private void SourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 		{
 			var newIndex = e.NewStartingIndex;
+			if (newIndex < 0) {
+				return;
+			}
 			Dispatcher.CurrentDispatcher.BeginInvoke(
 				DispatcherPriority.ApplicationIdle,
 				new Action(() => this.AssociatedObject.ScrollIntoView(this.AssociatedObject.Items[newIndex]))
-- 
GitLab