Pārlūkot izejas kodu

[Avalonia] Use post to ensure the gallery position update takes place after resize

Ruben 1 gadu atpakaļ
vecāks
revīzija
43c692e21f
1 mainītis faili ar 2 papildinājumiem un 9 dzēšanām
  1. 2 9
      src/PicView.Avalonia/Gallery/GalleryNavigation.cs

+ 2 - 9
src/PicView.Avalonia/Gallery/GalleryNavigation.cs

@@ -47,15 +47,8 @@ public static class GalleryNavigation
 
 
     public static void CenterScrollToSelectedItem(MainViewModel vm)
     public static void CenterScrollToSelectedItem(MainViewModel vm)
     {
     {
-        if (Dispatcher.UIThread.CheckAccess())
-        {
-            ScrollToSelected();
-        }
-        else
-        {
-            Dispatcher.UIThread.InvokeAsync(ScrollToSelected);
-        }
-        
+        // Use post to ensure the UI update takes place after resize
+        Dispatcher.UIThread.Post(ScrollToSelected, DispatcherPriority.Background);;
         return;
         return;
         void ScrollToSelected()
         void ScrollToSelected()
         {
         {