From afc143e1e446f42a16ad6c85b20d5dce1da4459f Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Tue, 19 Mar 2024 22:32:23 +0100 Subject: [PATCH] ControlUtils: Fix ScrollIntoView() --- Elwig/Helpers/ControlUtils.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Elwig/Helpers/ControlUtils.cs b/Elwig/Helpers/ControlUtils.cs index fcc014b..de449c4 100644 --- a/Elwig/Helpers/ControlUtils.cs +++ b/Elwig/Helpers/ControlUtils.cs @@ -183,10 +183,10 @@ namespace Elwig.Helpers { } else { input.SelectedItem = GetItemFromSource(input.ItemsSource, (int)hash); } - if (input is ListBox lb) { - lb.ScrollIntoView(lb.SelectedItem); - } else if (input is DataGrid dg) { - dg.ScrollIntoView(dg.SelectedItem); + if (input is ListBox lb && lb.SelectedItem is object lbItem) { + lb.ScrollIntoView(lbItem); + } else if (input is DataGrid dg && dg.SelectedItem is object dgItem) { + dg.ScrollIntoView(dgItem); } }