scrollable-base: fix layout problem when child relayouts 48/239548/1
authorLukasz Stanislawski <lukasz.stanislawski@gmail.com>
Mon, 27 Jul 2020 12:25:01 +0000 (14:25 +0200)
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>
Mon, 27 Jul 2020 12:25:01 +0000 (14:25 +0200)
In previous implementation there was no mechanims to inform
ScrollableBase to relayout when content changed.

This fix allows to remove some workaround code.

Change-Id: I7b09a92db2dc2a880043b7e0f6f767bbdf78af7c

Oobe/Oobe.Common/Controls/ScrollableBase.cs
Oobe/Oobe.Language/LanguageStep.cs

index 8461a37a8b9a09d53e800aa61e848d4193d6932f..cc36176fd36f2573a4cc82c5a013fbfd97178b8d 100644 (file)
@@ -415,9 +415,12 @@ namespace Oobe.Common.Controls
             {
                 propertyNotification.Notified -= OnPropertyChanged;
                 mScrollingChild.RemovePropertyNotification(propertyNotification);
+                mScrollingChild.Relayout -= OnChildRelayout;
             }
 
             mScrollingChild = view;
+            mScrollingChild.Relayout += OnChildRelayout;
+
             propertyNotification = mScrollingChild?.AddPropertyNotification("position", PropertyCondition.Step(1.0f));
             propertyNotification.Notified += OnPropertyChanged;
 
@@ -427,6 +430,11 @@ namespace Oobe.Common.Controls
             }
         }
 
+        private void OnChildRelayout(object sender, EventArgs args)
+        {
+            Layout.RequestLayout();
+        }
+
         /// <summary>
         /// Called after a child has been removed from the owning view.
         /// </summary>
index 93e57a46054388799d37e933ea6da445ee9c1fb9..b008b64a3af0479835f31644cbe1ac02b7bcf2f9 100644 (file)
@@ -86,16 +86,6 @@ namespace Oobe.Language
             container.PreviousButton.Hide();
             container.Content = carousel;
 
-            // workaround issue with ScrollableBase not properly scrolling
-            // to nth page during creation
-            Timer timer = new Timer(500);
-            timer.Tick += (sender, args) => {
-                int index = manager.Languages.FindIndex(x => x == manager.CurrentLanguage);
-                carousel.SelectedItemIndex = index;
-                return false;
-            };
-            timer.Start();
-
             return container;
         }
     }