Skip to content

Commit

Permalink
[Windows] Fix for ListView ScrollTo Method throws NullReferenceExcept…
Browse files Browse the repository at this point in the history
…ion (#26385)

* ListView ScrollTo issue fix

* Optimized the fix.

* Revert unwanted changes

* ListView ScrollTo issue fix

* Optimized the fix.

* Revert unwanted changes

* Enabling test cases.
  • Loading branch information
Tamilarasan-Paranthaman authored Dec 10, 2024
1 parent 9c038ca commit cf30c13
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.Maui.ApplicationModel;
using Windows.Foundation;
using Specifics = Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific.ListView;
using UwpScrollBarVisibility = Microsoft.UI.Xaml.Controls.ScrollBarVisibility;
Expand Down Expand Up @@ -597,12 +598,12 @@ async void ScrollTo(object group, object item, ScrollToPosition toPosition, bool
if (viewer == null)
{
RoutedEventHandler loadedHandler = null;
loadedHandler = async (o, e) =>
loadedHandler = (o, e) =>
{
List.Loaded -= loadedHandler;

// Here we try to avoid an exception, see explanation at bottom
await Control.Dispatcher.RunIdleAsync(args => { ScrollTo(group, item, toPosition, shouldAnimate, includeGroup); });
MainThread.BeginInvokeOnMainThread(() => { ScrollTo(group, item, toPosition, shouldAnimate, includeGroup); });
};
List.Loaded += loadedHandler;
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if TEST_FAILS_ON_WINDOWS //App was crashing while open on windows, getting Object Null Reference exception on ListViewRenderer, issue: https://github.com/dotnet/maui/issues/26345
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -22,5 +21,4 @@ public void Bugzilla42956Test()
App.WaitForElement(Success);
}
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_CATALYST // In Windows, getting object null reference exception while running the sample, Issue: https://github.com/dotnet/maui/issues/26345
//In MacCatalyst, Timeout Exception in the label line no 20. tried by using App.QueryUntilPresent, and adding delay also won't work.
#if TEST_FAILS_ON_CATALYST //In MacCatalyst, Timeout Exception in the label line no 20. tried by using App.QueryUntilPresent, and adding delay also won't work.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
Expand Down

0 comments on commit cf30c13

Please sign in to comment.